UTILS.
100% in-browser
🔡

Index of Coincidence Calculator

Compute the Index of Coincidence of text to detect cipher type and estimate Vigenère key length, with English-vs-random references and a column scan.

output

About this tool

The Index of Coincidence (IoC) Calculator computes a classic cryptanalysis statistic: the probability that two letters drawn at random from the text are the same. It filters the input to letters only, upper-cases it, counts each of the 26 letters n_i over a total of N letters, and evaluates IC = Σ n_i·(n_i − 1) / (N·(N − 1)). It also reports the normalized IC = IC × 26, scaled so that uniform random text sits near 1.0 and English plaintext near 1.73.

These reference values are what make the IoC useful. English plaintext has an IC around 0.0667 (normalized ≈ 1.73) because its letter distribution is far from flat, while uniform-random or well-mixed polyalphabetic ciphertext falls to about 0.0385 (normalized ≈ 1.00). A monoalphabetic substitution preserves the plaintext IC, so a high IC signals a simple cipher; a low IC signals a polyalphabetic one such as Vigenère.

For Vigenère key-length recovery, enter a maximum key length to run a column scan. The tool splits the text into k columns for each candidate k, computes the average IC across those columns, and flags the k whose average is closest to the English value — the likely key length, because splitting by the true period reassembles monoalphabetic columns. Everything is deterministic and computed offline in your browser; nothing is uploaded.

Frequently asked questions

What does the Index of Coincidence tell me?
It measures how uneven the letter distribution is. English plaintext has an IC around 0.0667 (normalized ≈ 1.73); random or polyalphabetic ciphertext drops to about 0.0385 (normalized ≈ 1.00). A high IC suggests plaintext or a monoalphabetic cipher; a low IC suggests a polyalphabetic cipher like Vigenère.
Why is the normalized IC useful?
Multiplying the raw IC by 26 rescales it so uniform random text sits at roughly 1.0 and English at roughly 1.73, giving an intuitive reference. It makes the ‘how close to English’ comparison easy to read without memorizing the small raw decimals.
How does the column scan estimate key length?
For each candidate key length k it splits the text into k columns (every k-th letter), computes the average IC of the columns, and flags the k whose average is closest to English (~0.0667). At the true Vigenère period each column is a single Caesar shift — monoalphabetic — so its IC rises toward the English value.
Does punctuation or case affect the result?
No. The tool strips everything except letters and upper-cases the rest before counting, so spaces, digits, and punctuation are ignored. Only the 26 letters A–Z contribute to N and the letter counts.

More tools