For nearly 300 years, the Vigenère cipher was considered unbreakable. It earned the nickname le chiffre indéchiffrable — “the indecipherable cipher.” It resisted every attack that worked against simple substitution ciphers because it uses multiple alphabets, which flattens the telltale frequency distribution that makes monoalphabetic ciphers so easy to crack.
But in the 19th century, Charles Babbage and Friedrich Kasiski independently discovered that the repeating key creates patterns — and patterns can be exploited. Parker Hitt described practical attacks in his 1916 Manual for the Solution of Military Ciphers, and William Friedman later formalized the mathematics with the Index of Coincidence.
If you are not familiar with how the Vigenère cipher works, start with the Vigenère cipher page first. This page walks you through a complete attack, step by step, using exactly the tools a real cryptanalyst would use.
The attack has five steps:
The first question is always: what kind of cipher is this? The Index of Coincidence (IC) answers that in a single number. English text has an IC around 0.067 because some letters (E, T, A) appear far more often than others. If a cipher preserves that uneven distribution (like a simple substitution or transposition), the IC stays near 0.067. If it flattens it (like the Vigenère), the IC drops toward 0.038 — the value for random text.
If the same plaintext letters happen to line up with the same key letters, they produce the same ciphertext. This creates repeated sequences (trigrams, tetragrams, etc.) in the ciphertext. For a genuine repeat — the same plaintext under the same key letters — the distance between the two copies is always a multiple of the key length. Chance repeats also occur, when different plaintext letters under different key letters happen to give the same three ciphertext letters, and their distances add noise to the tally.
The Kasiski examination finds these repeated sequences, measures the distances between them, and factors the distances. The key length divides every genuine distance; so does every divisor of the key length, which is why the tally alone is not enough (see the chart below). The tool checks each candidate by splitting the text into that many columns and measuring the columns’ Index of Coincidence.
Each distance between repeated trigrams is factored, and the factors are tallied. The true key length divides almost every distance — but so do its divisors: 2 divides every even distance, so for a 4-, 6- or 8-letter key the factor 2 is always at least as common as the true length. The tie is broken by the column IC shown beside each bar: split the text into the right number of columns and each column is a single Caesar alphabet with an IC near English (0.067); split it into a divisor of the key length and each column mixes two or three alphabets, so its IC sinks toward 0.05. The suggestion is the length that scores well on both.
Once we know (or guess) the key length, we split the ciphertext into that many columns. Each column contains every nth letter starting from a different position. Because each column was encrypted with a single key letter, each column is effectively a simple Caesar cipher.
If we chose the right key length, the IC of each column should be near 0.067 (English). If the ICs are low, the key length guess is probably wrong. Watch for ICs around 0.05: that is what a divisor of the real key length looks like (each column mixing two or three alphabets), so try two or three times the length before giving up on it.
Each column is a Caesar cipher — every letter in the column was shifted by the same amount (the corresponding key letter). We test all 26 possible shifts for each column and pick the one whose frequency distribution best matches English, using the chi-squared statistic. The shift with the lowest chi-squared value is the best match.
The shift number tells us the key letter: shift 0 = A, shift 1 = B, shift 2 = C, and so on. When we line up all the column shifts, we get the key.
We now have the recovered key. Applying it to the ciphertext should produce readable English.
This five-step process is essentially what Kasiski published in 1863 and what Friedman refined in the 1920s. The Index of Coincidence was Friedman's great contribution — it gave cryptanalysts a rigorous mathematical test where before they had relied on intuition and experience. But the core insight — that a repeating key creates exploitable patterns — goes back to Babbage in the 1850s.
Disclaimer: these pages are educational demos provided as-is, with no warranty of any kind. The author is not responsible for any consequences arising from their use.
Send comments and bug reports to chris@chrisspackman.com.
Version 0.1.5 — Last updated: 2026-10-25
This page is Copyright © 2025 – 2026
Chris Spackman <chris@chrisspackman.com>.
This web site developed entirely on GNU/Linux with Free / Open Source Software.
This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.