> For the complete documentation index, see [llms.txt](https://www.ctfrecipes.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://www.ctfrecipes.com/cryptography/mono-alphabetic-substitution/index-of-coincidence.md).

# Index of coincidence

The Index of Coincidence (IOC) is a statistical measure used in cryptography to analyze the randomness of a set of symbols.

A higher IOC value indicates a less random distribution of letters in the text and can be an indicator that a substitution cipher has been used. By comparing the IOC of a ciphertext to the expected IOC of plaintext in the same language, an attacker can make inferences about the encryption method used and use this information to break the cipher.

## How it works ?

To calculate an index of coincidence for a mono-alphabetic substitution, here is the equation :

$$
IC = \sum\_{q=A}^{q=Z} \frac{n\_q(n\_q-1)}{n(n-1)}
$$

{% hint style="info" %}
**n** is a total amount of letters within the text

***n\_A** is the amount of A*

***n\_B** is the amount of B etc.*
{% endhint %}

{% hint style="warning" %}
Note: This techniques only works if the provided text is large enough.
{% endhint %}

## Index of coincidence Table

Here is the "standard" indexes of coincidence for theses languages :

| Language   | Index of coincidence |
| ---------- | -------------------- |
| English    | 0,0667               |
| Serbian    | 0,0643               |
| Swedish    | 0,0644               |
| Esperanto  | 0,0690               |
| Greek      | 0,0691               |
| Norvégien  | 0,0694               |
| Norwegian  | 0,0707               |
| Finnish    | 0,0737               |
| Italian    | 0,0738               |
| Portuguese | 0,0745               |
| Arab       | 0,0758               |
| German     | 0,0762               |
| Hebrew     | 0,0768               |
| Spanish    | 0,0770               |
| Japanese   | 0,0772               |
| French     | 0,0778               |
| Dutch      | 0,0798               |
| malaysian  | 0,0852               |
| Russian    | 0,0529               |

## Resources

{% embed url="<https://gchq.github.io/CyberChef/#recipe=Index_of_Coincidence()>" %}

{% embed url="<https://www.dcode.fr/index-coincidence>" %}
