Chris Spackman's NeoCities Page

Breaking the Vigenère Cipher

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

The attack has five steps:

  1. IC Test — confirm the ciphertext is polyalphabetic (not monoalphabetic or transposition).
  2. Kasiski Examination — find repeated sequences to determine the key length.
  3. Split Columns — divide the ciphertext into columns, one per key letter.
  4. Break Columns — each column is a simple Caesar cipher; use chi-squared analysis to find each shift.
  5. Decrypt — apply the recovered key and read the plaintext.

Input

1. IC Test 2. Kasiski 3. Split Columns 4. Break Columns 5. Decrypt

Step 1: Index of Coincidence Test

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.

Full Ciphertext Frequency Distribution

Step 2: Kasiski Examination

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. The distances between these repeats are always multiples of the key length.

The Kasiski examination finds these repeated sequences, measures the distances between them, and looks for the most common factor. That factor is the most likely key length.

Repeated Trigrams

Factor Frequency Chart

Each distance between repeated trigrams is factored, and the factors are tallied. The factor that appears most often is the most likely key length.

Step 3: Split into Columns

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.

Step 4: Break Each Column

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.

Step 5: Decrypt

We now have the recovered key. Applying it to the ciphertext should produce readable English.

Historical Note

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.1 — Last updated: 2026-07-02

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.

Creative Commons License