Shifting the alphabet
The Caesar cipher, reportedly used by Julius Caesar for military correspondence, encrypts by shifting every letter of the alphabet forward by a fixed amount k: A becomes D under a shift of 3, B becomes E, and so on, wrapping from Z back to A. Decryption just shifts backward by the same k. It has exactly 25 possible keys (26 minus the useless shift of 0), which means it offers essentially no real security — a computer, or a patient human, can simply try all 25 shifts and read off which one produces English.
Vigenère: a different shift for every letter
The Vigenère cipher (16th century, long misattributed and once called "le chiffre indéchiffrable") fixes the single-shift weakness by repeating a keyword under the plaintext and using each keyword letter's own alphabet position as that position's shift.
plaintext: A T T A C K A T D A W N
key: L E M O N L E M O N L E
ciphertext: L X F O P V E F R N H R (each letter shifted by its aligned key letter)
C_i = (P_i + K_{i mod m}) mod 26, m = key length
Because the shift changes letter by letter following the keyword, the same plaintext letter usually encrypts to different ciphertext letters at different positions, which flattens the single-alphabet letter-frequency pattern that makes Caesar so breakable — for nearly three centuries this genuinely resisted casual cryptanalysis.
Breaking Caesar: frequency analysis
English letter frequencies are famously uneven: E appears about 12.7% of the time, T about 9.1%, while J, Q, X and Z barely register. Under a Caesar shift, this entire frequency profile just slides by k positions, so an attacker measures the ciphertext's letter frequencies, finds the shift that best aligns the peak (usually the ciphertext's most common letter mapping back to E) with known English statistics, and recovers k directly — exactly the automated highlight this simulation performs on the live frequency chart.
Breaking Vigenère: finding the key length first
Vigenère resists simple frequency analysis on the whole ciphertext because 26 different shift alphabets are interleaved. The classical attack, Kasiski examination, instead looks for repeated substrings in the ciphertext; if the same plaintext fragment happens to align with the same part of the repeating key twice, it produces an identical ciphertext substring, and the distance between repeats is very likely a multiple of the key length m. Once m is known, the ciphertext splits into m independent Caesar-shifted streams (every m-th letter shares one shift), and ordinary frequency analysis breaks each one separately.
The index of coincidence: measuring 'how English' a stream looks
The index of coincidence (IC) gives a more robust, statistical way to find m without hunting for repeats. It measures the probability that two randomly chosen letters from a text are identical.
IC = Σ n_i(n_i − 1) / (N(N − 1)) n_i = count of letter i, N = total letters random text (26 equiprobable letters): IC ≈ 0.038 normal English text: IC ≈ 0.067 Vigenère split at the correct key length m: each of the m streams is single-shifted English, so its IC lands near 0.067; split at the wrong length, the streams behave closer to random and IC drops toward 0.038.
Trying candidate key lengths and picking the one whose split streams show the highest average IC pins down m reliably, after which the same frequency-analysis attack that breaks Caesar breaks each of the m streams in turn — the two attacks in this simulation are, in the end, the same idea applied once and then m times in parallel.
Frequently asked questions
Why is the Caesar cipher considered completely insecure today?
It has only 25 possible keys, so exhaustively trying every shift and checking which one produces readable text breaks it in a fraction of a second, even by hand. Its letter-frequency profile also stays intact, just shifted, which makes frequency analysis an even faster attack.
Why was Vigenère considered unbreakable for so long?
Because it uses a different shift for each position in the repeating key, which smooths out the single-alphabet frequency pattern that makes Caesar-style ciphers vulnerable, and without knowing the key length there's no obvious way to separate the interleaved shift alphabets. It took Kasiski's 1863 method of finding repeated ciphertext substrings to reliably recover the key length and break it systematically.
What does the index of coincidence actually measure?
The probability that two randomly picked letters from a text are the same letter. Because English letter frequencies are uneven, English text has a noticeably higher IC (around 0.067) than random text (around 0.038), which is exactly the signal used to find where a Vigenère ciphertext splits back into single-shift English streams.
Try it live
Everything above runs in your browser — open Caesar & Vigenère Ciphers and change the parameters while it is running. Nothing is installed, nothing is uploaded, the whole model lives in one tab.
▶ Open Caesar & Vigenère Ciphers simulation