05 — Classical
Vigenère Cipher (Original)
Polyalphabetic — rotates the substitution alphabet using a keyword. Defeats simple frequency analysis.
Mathematical definition
Key = a word of length L, repeated to message length. Letters A=0, B=1, …, Z=25.
# Encryption: each plaintext letter shifted by the key letter
C_i = (P_i + K_i mod L) mod 26
# Decryption: reverse the shift
P_i = (C_i − K_i mod L) mod 26
Theory — Tabula Recta
Vigenère = L Caesar ciphers interleaved. Row = key letter, column = plaintext letter, cell = ciphertext. Position i uses alphabet i mod L, so the same P encrypts differently at different positions — flattening single-letter frequencies.Worked example
Key : L E M O N L E M O N L
Plain : A T T A C K A T D A W N
Shift : 11 4 12 14 13 11 4 12 14 13 11
Cipher : L X F O P V E N D A H L
// A(0)+L(11)=11→L T(19)+E(4)=23→X T(19)+M(12)=31 mod26=5→F ...
Strength
The same plaintext letter maps to different ciphertext letters depending on position, so simple letter-frequency analysis fails. For 300 years it was called "le chiffre indéchiffrable".
Weakness — key length is the footing
If key length L is known, the cipher decomposes into L independent Caesar ciphers — each breakable by frequency analysis on every L-th letter.
Kasiski Test (1863) — worked
Find repeated ciphertext blocks (≥3 letters). Measure distances between repeats. The GCD of distances is (almost certainly) L or a multiple of L.# e.g. block "VEND" repeats at positions 6, 18, 30
distances: 18−6 = 12, 30−18 = 12, 30−6 = 24
gcd(12, 12, 24) = 12 → L divides 12 (try 2,3,4,6,12)
Then attack each of the L sub-ciphers with single-letter frequencies.Friedman Test (1920) — Index of Coincidence
Uses IC to estimate L statistically:IC = Σ f_i·(f_i − 1) / N·(N − 1) # f_i = count of letter i
IC ≈ 0.0385 random text, ≈ 0.0667 English
L ≈ 0.027·N / ((N−1)·IC − 0.038·N + 0.065)
Compute IC of the ciphertext; values near 0.066/L + 0.038(L−1)/L reveal L. Needs ~100+ letters but is fully automatic.Exam one-liner: Vigenère = L Caesars. Kasiski finds L from repeats, Friedman from statistics — then each Caesar falls to frequency analysis.