Index of Coincidence Calculator
Measure how lumpy a text's letter distribution is, and read the key length straight off the column table.
Try:
Paste some text to measure it. The Caesar and Vigenere samples are the same passage as the English one, so you can watch what each kind of cipher does to the number.
How to use Index of Coincidence Calculator
- 1
Paste the text
Drop plaintext or ciphertext into the box. Only A-Z letters take part; case, spaces, digits and punctuation are ignored, so formatting cannot move the number.
- 2
Read the index
The raw IC is the probability that two letters drawn at random are the same letter. The normalised figure is that value against a uniform alphabet, where 1.00 is random and about 1.73 is English.
- 3
Decide what kind of cipher you have
Around 0.066 means the letter distribution is intact, so the text is plaintext or a simple substitution. Around 0.038 means it has been flattened, which points at a repeating-key cipher.
- 4
Find the key length in the column table
If the text looks polyalphabetic, look for the shortest length whose column IC climbs back towards 0.066. That is the key length, and it is the number the Vigenere solver needs.
The Index of Coincidence, explained
One number, one question
The Index of Coincidence answers a narrow question: if you reach into a text twice and pull out a letter each time, how often do you get the same letter twice? For a bag of 26 equally common letters the answer is 1 in 26, about 0.0385. For English it is nearly twice that, about 0.066, because English is not an even bag. E, T, A and O do an enormous amount of the work and J, Q, X and Z barely turn up.
That gap is the whole of the statistic's usefulness. It survives relabelling: if you swap every A for a Q and every Q for an A, the counts move but the lumpiness does not, so the index is unchanged. It does not survive being spread across several alphabets, which is exactly what a repeating-key cipher does.
What it can and cannot tell you
An IC near 0.066 says the letter distribution is intact. That covers ordinary plaintext, a Caesar shift, an Atbash mirror and any simple substitution cipher, and it is why a monoalphabetic cipher is broken with frequency analysis rather than with this number.
An IC near 0.038 says the distribution has been flattened. Something is mapping one plaintext letter to several ciphertext letters, which is the signature of Vigenere and its relatives, or of a genuinely random string.
A reading in between usually means the text is too short rather than that the cipher is unusual. Under about a hundred letters the index bounces around enough to be misleading, and under about three hundred it is worth treating as a hint rather than a verdict.
The column table is the part that does the work
The single number for the whole text tells you the kind of cipher. Finding the key length takes a second step, and it is the step most calculators leave out.
Take the letters and deal them into L piles: positions 1, L+1, 2L+1 into the first pile, positions 2, L+2 into the second, and so on. If L is the real key length then every letter in a pile was shifted by the same key letter, so that pile is a Caesar cipher of English and keeps English's lumpiness. If L is wrong, each pile mixes letters that were shifted by different amounts and comes out flat.
So the column IC, averaged across the piles, rises at the true key length and at every multiple of it. Reading down the table for the first length that jumps is the classical way to find a Vigenere key length, and it is more reliable than the Friedman formula on real texts.
Where to go next
If the column table points at a length, Kasiski examination is the natural second opinion: it works from the distances between repeated sequences instead of from letter statistics, so it fails in different places. Two independent methods agreeing on the same number is much stronger evidence than either alone.
Once you are confident about the length, the Vigenere solver will take the ciphertext, split it into that many columns, break each one as a Caesar cipher and hand back the keyword and the plaintext.
Frequently asked questions
What is the Index of Coincidence?
Why does my number differ from another calculator?
How does the Index of Coincidence find a key length?
What is the Friedman estimate and should I trust it?
Why do 5 and 10 and 15 all score well?
Can it tell me what language a text is in?
Does my text leave my browser?
Related tools
Keep going with these handy tools