Index of coincidence calculator

The IC of a text with the counts written out, Friedman's estimate, and the average IC of the columns for every period, to find a Vigenère key length.

How it works

The index of coincidence is the probability that two letters taken from two different positions of a text are equal. Counting $n_i$ letters of each kind among $N$, it is $\mathrm{IC} = \sum_i n_i (n_i - 1) / (N (N - 1))$. For English it is close to $\kappa_p = \sum_i p_i^2 \approx 0.066$; for letters chosen uniformly at random it is $\kappa_r = 1/26 \approx 0.0385$.

Relabelling the letters, as a substitution does, leaves the IC unchanged. A Vigenère cipher, however, uses $L$ alphabets in turn, and its IC falls toward $\kappa_r$. William Friedman turned this into an estimate of $L$ in the 1920s.

The more reliable test splits the ciphertext into $p$ columns (every $p$-th letter) and averages the IC of the columns. When $p$ equals the key length, each column was enciphered with a single Caesar shift, so its IC jumps back to the English value. Multiples of the key length score high as well, so the smallest high period is the answer.

Everything is calculated in your browser. Nothing you type leaves your device.