The Vigenère cipher

A Caesar cipher shifts every letter by the same amount. Type a message and a keyword. Vigenère shifts the first letter of the message by the first letter of the key (A = 0, B = 1, …), the second by the second, and the key repeats. The same plaintext letter can come out differently each time, which spoils simple letter counting. For 300 years it was called "the unbreakable cipher". Before you change the keyword, predict what the bars will do. Try LEMON, then AAAAA, BBBBB and ABCABC.

Result

Letter counts of the ciphertext

Letter counts if the same message were a Caesar shift of 3 (one tall bar: probably E in disguise, if the message is ordinary English)

What's going on

With one shift, the tallest bar in the ciphertext is usually E in disguise, because E is the commonest letter in ordinary English. That is a guess about the message, not a law. Write BANANA a hundred times and shift by 3: A is 300 of the 600 letters, so the tallest bar is D, and "D must be E" gives the wrong key. A frequency guess needs two things: a message that behaves like English, and a check that the decoded result actually reads.

With a keyword like LEMON, each letter of the message is shifted by one of five different amounts, so the counts are smeared out and the bars go flat. But what matters is the shortest repeating block of the key, not the length you typed. AAAAA has entered length 5 and effective period 1: it leaves the message untouched and the English bars survive. BBBBB is a Caesar shift of 1. ABCABC has entered length 6 and effective period 3. The readout above the strip tells them apart.

In 1863 Friedrich Kasiski noticed a weakness. When a common word like THE appears twice at a distance that is a multiple of the period, both copies meet the same key letters and encrypt identically, so the distance between genuine repeats is a multiple of the period. Two cautions. Some three-letter repeats are accidents, and their distances mean nothing. And if the period is 5, then 5 divides every genuine distance, but other numbers can too: 1 always does, and 10 or 15 may divide some of the distances you happen to see. The factor list points at candidates, not an answer. Pick a candidate period, split the ciphertext into that many lanes, break each lane as a Caesar cipher, and read the result. If it is not English, the candidate was wrong, or a lane's tallest bar was not E.

Sheet: Secret codes and how to break them.