Toolstia / Index of coincidence calculator

index of coincidence calculator

The index of coincidence tells you how uneven the letter frequencies in a text are. It is a first step in breaking classical ciphers, because it separates ordinary language from polyalphabetic ciphertext and helps find the key length.

The index of coincidence is the chance that two letters picked at random from the text are the same. English is about 0.0667 (1.73 normalised) and random letters are about 0.0385 (1.00). A simple substitution cipher keeps the English value, while a Vigenere cipher pushes it down. Splitting the text into columns for each possible key length and finding the length where the average rises towards 0.066 is the classic way to find the key length. You need a few hundred letters for a reliable answer.

How it works

  1. Paste the text or ciphertext.
  2. Read the index of coincidence and what it suggests.
  3. Check the table of average values to find the likely key length.

What the number means

English text gives about 0.0667 (1.73 when multiplied by 26). Random letters give about 0.0385 (1.00). A simple substitution cipher keeps the English value, while a Vigenere cipher with a long key moves towards random.

Key length table

For each key length from 1 to 20 the text is split into columns and the index of each column is averaged. The length where the average jumps up towards 0.066 is probably the key length or a multiple of it.

Friedman estimate

The Friedman test gives a rough key length from the index alone. It needs a few hundred letters to be reliable.

Letters only

Only the letters A to Z are counted. Case, spaces, digits and punctuation are ignored.

Questions

Is my text uploaded?

Everything happens in your browser, and nothing you enter is sent anywhere.

How much text do I need?

At least 100 letters for a rough idea, and 300 or more for reliable key length results.

Does it work for other languages?

The ranges quoted are for English. Other languages have their own typical values, for example about 0.078 for French.