How to Break a Vigenère Cipher Without the Key: A Worked Example
Step-by-step cryptanalysis of a real Vigenère ciphertext: find the key length with Kasiski examination and the index of coincidence, then recover each key letter with chi-squared frequency analysis.
By Abdessamad Bettal··8 min read
Key takeaways
- Breaking Vigenère is two problems: find the key length, then solve each key position as a Caesar cipher.
- Kasiski examination: repeated sequences in the ciphertext tend to be spaced at multiples of the key length.
- Index of coincidence (IoC): split the ciphertext into columns for each candidate length. At the right length the columns look like English (IoC ≈ 0.066); at wrong lengths they look random (≈ 0.038).
- Chi-squared: for each column, try all 26 shifts and pick the one whose letter frequencies are closest to English. The winning shifts spell the key.
- In our worked example — 405 letters — the IoC jumps from 0.044 to 0.073 at length 7, and chi-squared recovers the key LANTERN with no guessing.
For three centuries the Vigenère cipher was called *le chiffre indéchiffrable* — the indecipherable cipher. It defeats the simple frequency analysis that breaks a Caesar cipher, because the same plaintext letter encrypts to different ciphertext letters depending on its position. Then, in 1863, Friedrich Kasiski published a general attack (Charles Babbage had found one privately a decade earlier). Today it's a standard CTF challenge, and breaking one by hand is the best introduction to real cryptanalysis there is.
This guide breaks a real ciphertext step by step. Every number below was computed with the same functions that power our Vigenère tool and frequency analysis tool, so you can follow along.
How Vigenère works (in one paragraph)
Pick a keyword, say KEY. Write it repeatedly under the plaintext, then shift each plaintext letter forward by the alphabet position of the key letter above it (A=0, B=1, … Z=25). With key KEY, the 1st, 4th, 7th… letters are shifted by 10 (K), the 2nd, 5th, 8th… by 4 (E), and the 3rd, 6th, 9th… by 24 (Y). It's simply several interleaved Caesar ciphers — and that's its weakness.
The challenge
Here is our ciphertext. Spaces and punctuation were left in place, which is common in puzzles (and makes life easier):
Ehr fijfpntxv crqt gai yncbbk fvszrr wena naekczar a fxecro lrmxve qoe mlv tzvrkrfe. Yoohhp by tux wyva kaxa nult gai cretrk wrvo, bhm imrcybgi bapw vm qrgeeexh, srnahli kup cnixrvy hnw hfhmlrw xyr hagvl rao fbkfzqoea trp ytgumw fa oepd ewgpr fnrjre. Oa mlv gsiew rztst n lxfex cnfi fhe os mlv jpsg tru gse pkin ylsuxh kup cnkkf gz tux qrfe. Wuxr kup sxr gcrlrrw xyr xeflietpr jtw xbye, ngh jb haf mlv yptgxv. Kup cnixrvy srtvtupd roiil naobr rao fbnru byll tr vzatl vlrvc aaw e tnydyx xyne wnl wkvwl jtvd.First, a quick sanity check with the frequency analysis tool: the 405 letters have an index of coincidence of 0.0448. English text scores around 0.066–0.073 (the plaintext here scores 0.0728); uniformly random letters score 0.0385. A value in between is the classic signature of a polyalphabetic cipher like Vigenère — a Caesar or simple substitution cipher would keep the English value.
Step 1a: Kasiski examination
When the same plaintext fragment happens to line up with the same part of the key, it produces the same ciphertext. Common words like *the* make this likely. So: find repeated sequences of three or more letters (ignoring spaces) and measure the distances between them.
| Trigram | Positions | Distance | Factors |
|---|---|---|---|
| MLV | 59, 206, 234, 318 | 147, 28, 84 | 3·7², 2²·7, 2²·3·7 |
| KUP | 138, 257, 278, 327 | 119, 21, 49 | 7·17, 3·7, 7² |
| CNI…XRV…RVY | 141 → 330 | 189 | 3³·7 |
| XYR | 158, 291 | 133 | 7·19 |
| TGA / GAI | 15, 92 | 77 | 7·11 |
| RRW | 29, 288 | 259 | 7·37 |
| QOE | 56, 174 | 118 | 2·59 |
| RFE | 67, 271 | 204 | 2²·3·17 |
Almost every distance is a multiple of 7. Two aren't — 118 and 204 — which is normal: some repeats are coincidences, not alignments. Kasiski gives you strong candidates, not certainty; the next test confirms.
Step 1b: index of coincidence by key length
If the key length is L, then letters 1, L+1, 2L+1… were all shifted by the same key letter. Each such column is a Caesar cipher of English, so its index of coincidence should look like English (~0.066). At the wrong length, each column mixes several shifts and looks random (~0.038). Compute the average column IoC for each candidate length:
| Key length | Average IoC | |
|---|---|---|
| 1 | 0.0448 | |
| 2 | 0.0444 | |
| 3 | 0.0467 | |
| 4 | 0.0438 | |
| 5 | 0.0438 | |
| 6 | 0.0442 | |
| 7 | 0.0734 | ← English-like |
| 8 | 0.0428 | |
| 9 | 0.0441 | |
| 10 | 0.0414 | |
| 11 | 0.0442 | |
| 12 | 0.0447 | |
| 14 | 0.0696 | multiple of 7 |
| 21 | 0.0888 | multiple of 7 |
There's no ambiguity: length 7 jumps to 0.073, matching English, while every other length up to 12 stays near 0.044. Multiples of the true length — 14 and 21 — also score high (21 even higher, because its columns are so short that the statistic gets noisy), so always prefer the smallest length that spikes.
Step 2: recover each key letter with chi-squared
Now split the 405 letters into 7 columns of 57–58 letters. Each column is a Caesar cipher. For each one, try all 26 shifts and measure how close the resulting letter frequencies are to English using the chi-squared statistic:
χ² = Σ (observed_count − expected_count)² / expected_count
over the 26 letters, where expected = English frequency × column length
Lower χ² = closer to English.| Column | Best shift | χ² | Runner-up | χ² |
|---|---|---|---|---|
| 1 | L | 24.7 | W | 86.9 |
| 2 | A | 22.1 | L | 163.8 |
| 3 | N | 15.6 | A | 122.1 |
| 4 | T | 27.3 | F | 159.5 |
| 5 | E | 31.3 | D | 147.5 |
| 6 | R | 16.0 | C | 212.8 |
| 7 | N | 15.1 | A | 174.5 |
In every column the best shift beats the runner-up by a wide margin — a χ² in the 15–30 range against 87–213. Read the winning shifts top to bottom: L-A-N-T-E-R-N. Decrypt with key LANTERN:
The messenger left the harbor before dawn carrying a sealed letter for the
governor. Nobody on the ship knew what the letter said, but everyone knew it
mattered, because the captain had doubled the watch and forbidden any lights
on deck after sunset. …You can reproduce this: paste the ciphertext into the Vigenère tool, choose *decrypt*, and enter LANTERN. Then try a wrong key of the same length and watch the output turn to noise.
Doing it by hand: the mutual-shift shortcut
Without a computer, computing 26 chi-squared scores per column is tedious. A faster manual trick: in each column, find the most common letter and assume it's E. Column 4's most frequent letter is X (10 times), so the shift is X − E = 23 − 4 = 19 = T — correct.
| Column | Top letters | Assume top = E | Actual key | |
|---|---|---|---|---|
| 1 | P ×11, E ×7, Y ×7 | L | L | ✓ |
| 2 | T ×8, A ×7, E ×6 | P | A | ✗ — plaintext T outnumbered E |
| 3 | R ×9, N ×8, G ×5 | N | N | ✓ |
| 4 | X ×10, M ×8, K ×7 | T | T | ✓ |
| 5 | I ×10, R ×9, X ×7 | E | E | ✓ |
| 6 | R ×8, V ×7, F ×6 | N | R | ✗ — V (= E) was second |
| 7 | R ×9, A ×6, V ×6 | N | N | ✓ |
Five of seven letters come out right, and the misses are instructive: with only 58 letters per column, T or A can outnumber E by chance. That's why chi-squared, which uses all 26 frequencies at once, is more reliable. By hand, check whether the top two or three letters can play the roles of E, T and A consistently, then fix doubtful letters by reading the partial decryption. The shortcut's key LPNTENN decrypts to text where only the 2nd and 6th letter of every 7-letter group is wrong, and it's easy to see which shift turns Tse back into The.
When it doesn't work
- Autokey variant — the key is the keyword followed by the plaintext itself, so there's no repeating period and Kasiski/IoC find nothing. Attack it by guessing the keyword length and probable words instead. Our tool supports autokey too.
- Running key / book cipher — a long text as the key. Breakable with statistics on both texts, but much harder.
- Key as long as the message and truly random — that's a one-time pad, and it's provably unbreakable.
- Very short ciphertext — with only a few letters per column, there isn't enough statistical signal. Try dictionary attacks on likely keywords instead.
- Spaces removed and letters grouped in fives — no problem for these methods, which ignore non-letters anyway.
Why this still matters
Vigenère's failure teaches a lesson every modern cipher is designed around: any repetition in the keystream is exploitable. The same mistake reappears in reused one-time pads, in repeating-key XOR (which falls to exactly this attack — try our XOR bruteforcer), and in stream ciphers like AES-CTR or ChaCha20 when a nonce is reused. Modern ciphers avoid it by making the keystream effectively infinite and never repeating it under the same key.
Practice workflow for CTFs
- Run frequency analysis: IoC near 0.066 → Caesar/substitution; near 0.04–0.05 → polyalphabetic.
- If it's monoalphabetic and only shifted, use the Caesar bruteforce.
- If polyalphabetic, find the period with Kasiski + IoC.
- Solve each column with chi-squared, decrypt, and sanity-check the plaintext.
- If nothing works, consider transposition (rail fence), Playfair, or an encoding layer such as Base64 on top.
Frequently asked questions
Can you decrypt a Vigenère cipher without the key?
+
Yes, given enough ciphertext. Find the key length using Kasiski examination and the index of coincidence, then recover each key letter by treating every key position as a Caesar cipher and choosing the shift whose letter frequencies best match English.
What is the index of coincidence?
+
It is the probability that two randomly chosen letters from a text are the same. English text scores about 0.066, while random letters score about 0.038. It helps identify the cipher type and the Vigenère key length.
How much ciphertext do you need to break Vigenère?
+
As a rule of thumb, at least 20 to 30 letters per key position for statistics to be reliable. A 7-letter key therefore needs roughly 150 to 200 letters; our 405-letter example gave an unambiguous result.
What is Kasiski examination?
+
A method published by Friedrich Kasiski in 1863. It finds repeated sequences in a Vigenère ciphertext and measures the distances between them; the key length is likely a common factor of those distances.
Tools used in this guide
Vigenère Cipher
The polyalphabetic cipher that resisted breaking for 300 years
ANALYSIS · χ² · ICFrequency Analysis
Letter statistics, index of coincidence, chi-square
CAESAR · SHIFTCaesar Cipher
Shift cipher with instant all-25 bruteforce
XOR · BRUTEFORCEXOR Cipher
Bitwise XOR with a repeating key, plus single-byte bruteforce
Encoding vs Encryption vs Hashing: The Difference, With Examples
Encoding, encryption and hashing all turn data into gibberish, but only one keeps secrets. Learn the difference with real Base64, AES and SHA-256 examples and when to use each.
6 MIN READSYMMETRIC · AESAES-GCM vs CBC vs CTR vs ECB: Which AES Mode Should You Use?
AES is only as safe as its mode. Compare ECB, CBC, CTR and GCM — how each works, how each fails, and why AES-GCM (or ChaCha20-Poly1305) is the right default in 2026.
7 MIN READKDF · PASSWORDSArgon2id vs bcrypt vs scrypt vs PBKDF2: Password Hashing in 2026
Which password hashing algorithm should you use? A practical comparison of Argon2id, bcrypt, scrypt and PBKDF2 with OWASP-recommended parameters, hash formats, pitfalls and migration steps.
6 MIN READ