Vigenere Key Length Calculator

The Vigenere cipher encrypts text with a repeating keyword, and the first step in breaking it is finding the length of that keyword. The Friedman test estimates the key length from the index of coincidence of the ciphertext, a statistical measure of how evenly the letters are distributed. This educational tool computes the index of coincidence of the text you paste and applies the Friedman formula to estimate the most likely key length. It works best on longer ciphertexts and is intended for learning classical cryptanalysis, not for attacking real systems.

0.00
0.00
0.00
0.00

Friedman test formula

IC = sum( count_i * (count_i - 1) ) / ( N * (N - 1) )
L = (0.0265 * N) / ( (0.0665 - IC) + N * (IC - 0.0385) )

IC is the index of coincidence, count_i is how many times letter i appears, and N is the total letter count. The constants 0.0665 (English IC), 0.0385 (random IC) and 0.0265 are the standard values used in the Friedman key length estimate. The most likely key length is the estimate rounded to the nearest whole number.

Worked example

Suppose a 200-letter ciphertext has an index of coincidence of 0.0420. Then L = (0.0265 * 200) / ((0.0665 - 0.0420) + 200 * (0.0420 - 0.0385)) = 5.30 / (0.0245 + 0.70) = 5.30 / 0.7245 = 7.32. The most likely key length is therefore 7. A cryptanalyst would test key lengths near 7 with the Kasiski examination to confirm.

Vigenere key length: frequently asked questions

How does the Friedman test estimate Vigenere key length?

The Friedman test computes the index of coincidence (IC) of the ciphertext, the probability that two randomly chosen letters are the same. For English plaintext the IC is about 0.0667 and for random text about 0.0385. The estimated key length L is given by L = (0.0265 * N) / ((0.0665 - IC) + N * (IC - 0.0385)), where N is the ciphertext length.

What is the index of coincidence?

The index of coincidence is the sum over each letter of its count times its count minus one, divided by the total length times the total length minus one. It measures how unevenly letters are distributed. English text has a higher IC (around 0.0667) than random text (around 0.0385) because some letters appear far more often.

Why is the key length only an estimate?

The Friedman test is statistical. Short ciphertexts produce noisy IC values, so the estimate can be off by one or more. It works best on longer ciphertexts (a few hundred letters or more). For a precise result, cryptanalysts combine it with the Kasiski examination, which looks at distances between repeated sequences.

What text should I paste in?

Paste the ciphertext only. The calculator ignores spaces, digits, and punctuation, and treats upper and lower case the same. Only the 26 letters A to Z are counted. Longer ciphertext gives a more reliable key length estimate.

Sources and method

  • William F. Friedman, "The Index of Coincidence and Its Applications in Cryptanalysis" (Riverbank Publication No. 22, 1922), which introduced the method.
  • The index of coincidence and the key length estimate are fixed statistical formulas; this tool computes them directly from your ciphertext.

Reviewed by the CalculatorHub team, edited by James Graham, 19 June 2026. See our methodology.