Tool to compute coincidence index (IoC) in cryptanalysis, in order to study the probability of finding repeating letters in an encrypted text.

Index of Coincidence - dCode

Tag(s) : Cryptanalysis

dCode is free and its tools are a valuable help in games, maths, geocaching, puzzles and problems to solve every day!

A suggestion ? a feedback ? a bug ? an idea ? *Write to dCode*!

The **index of coincidence** is an indicator used in cryptanalysis which makes it possible to evaluate the global distribution of letters in encrypted message for a given alphabet.

A text written in English language has an **index of coincidence** of 0.0667, but some ciphers modify this value which can allow them to be recognized.

**Index of coincidence** uses the formula:

$$ IC = \sum_{i=A}^{i=Z} \frac{n_{i}(n_{i}-1)}{N(N-1)} $$

with $ n_i $ the number of occurrences of the letter $ i $ in the text and $ N $ the total number of letters.

For a given ciphered message, the value for the IoC allows to filter the list of ciphering methods to use. It is one of the first cryptanalysis technique.

If the **Index of coincidence** is high (close to $ 0.070 $), i.e. similar to plain text, then the message has probably been crypted using a transposition cipher (letters were shuffled) or a monoalphabetic substitution (a letter can be replaced by only one other).

If the **Index of coincidence** is low (close to $ 0.0385 $), i.e. similar to a random text, then the message has probably been crypted using a polyalphabetic cipher (a letter can be replaced by multiple other ones).

The more the coincidence count is low, the more alphabets have been used.

__Example:__ Vigenere cipher with a key of length 4 to 8 letters have an IC of about $ 0.045 \pm 0.05 $

For an non encrypted text, coincidence indexes are

English | 0.0667 | French | 0.0778 |
---|---|---|---|

German | 0.0762 | Spanish | 0.0770 |

Italian | 0.0738 | Russian | 0.0529 |

A text where each letter has the same probability of appearance than another, IC is then of $ 1/N $ (where $ N $ is the number of letters in the alphabet)

__Example:__ $ IC = 0.0385 $ for $ N=26 $

Examples of codes in programming languages `// Python`

def ic(self):

num = 0.0

den = 0.0

for val in self.count.values():

i = val

num += i * (i - 1)

den += i

if (den == 0.0):

return 0.0

else:

return num / ( den * (den - 1))

dCode retains ownership of the online 'Index of Coincidence' tool source code. Except explicit open source licence (indicated CC / Creative Commons / free), any 'Index of Coincidence' algorithm, applet or snippet (converter, solver, encryption / decryption, encoding / decoding, ciphering / deciphering, translator), or any 'Index of Coincidence' function (calculate, convert, solve, decrypt / encrypt, decipher / cipher, decode / encode, translate) written in any informatic language (Python, Java, PHP, C#, Javascript, Matlab, etc.) and no data download, script, copy-paste, or API access for 'Index of Coincidence' will be for free, same for offline use on PC, tablet, iPhone or Android ! dCode is free and online.

Please, check our dCode Discord community for help requests!

NB: for encrypted messages, test our automatic cipher identifier!

index,coincidence,counting,ic,cryptanalysis,friedman,kullback,polyalphabetic,monoalphabetic,key,repetition,letter,probability,ioc

Source : https://www.dcode.fr/index-coincidence

© 2021 dCode — The ultimate 'toolkit' to solve every games / riddles / geocaching / CTF.

Feedback

▲
Thanks to your feedback and relevant comments, dCode has developed the best 'Index of Coincidence' tool, so feel free to write! Thank you!