How the Vigenère cipher works
The Vigenère cipher is a set of Caesar ciphers taken in turn. Each letter of the keyword gives a shift — A = 0, B = 1, … Z = 25 — and the keyword is repeated along the message. The first letter of the message is shifted by the first key letter, the second by the second, and so on. Because the same plaintext letter can turn into different ciphertext letters, simple letter-frequency counting does not work the way it does against a Caesar cipher.
Worked example: ATTACKATDAWN with the key LEMON
| Plain | 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 |
| Shift | 11 | 4 | 12 | 14 | 13 | 11 | 4 | 12 | 14 | 13 | 11 | 4 |
| Cipher | L | X | F | O | P | V | E | F | R | N | H | R |
A shifted by L (11) gives L, T shifted by E (4) gives X, T shifted by M (12) gives F, and so on, producing LXFOPVEFRNHR — the classic textbook example. To decrypt, subtract each key shift instead of adding it.
The Vigenère square
Before calculators, people used a table of 26 shifted alphabets, the tabula recta. Find the plaintext letter along the top and the key letter down the side; the ciphertext letter is where they meet. A few rows of it:
| A | ABCDEFGHIJKLMNOPQRSTUVWXYZ |
|---|---|
| B | BCDEFGHIJKLMNOPQRSTUVWXYZA |
| C | CDEFGHIJKLMNOPQRSTUVWXYZAB |
| D | DEFGHIJKLMNOPQRSTUVWXYZABC |
| E | EFGHIJKLMNOPQRSTUVWXYZABCD |
| L | LMNOPQRSTUVWXYZABCDEFGHIJK |
| M | MNOPQRSTUVWXYZABCDEFGHIJKL |
| N | NOPQRSTUVWXYZABCDEFGHIJKLM |
| O | OPQRSTUVWXYZABCDEFGHIJKLMN |
Row L starts with L, so plaintext A under key L gives L — matching the first letter of the worked example.
Case, spaces and punctuation
This tool keeps the shape of your message: capitals stay capital, lowercase stays lowercase, and spaces, digits and punctuation pass through untouched. The key advances only on letters, which is the usual convention, so “Attack at dawn!” with the key LEMON becomes “Lxfopv ef rnhr!”. Some puzzle books strip spaces and write ciphertext in five-letter groups instead; the letters are the same either way. Non-letters in the key are ignored.
History
According to Encyclopaedia Britannica, the cipher was invented in 1553 by the Italian cryptographer Giovan Battista Bellaso, but for centuries was attributed to the French cryptographer Blaise de Vigenère, who devised a similar cipher in 1586. It earned the nickname le chiffre indéchiffrable — “the indecipherable cipher” — and was long believed to be unbreakable.
How it is broken
The weakness is the repeating key. In the 19th century Friedrich Kasiski showed that repeated fragments of ciphertext reveal the key length; once that is known, the message splits into several Caesar ciphers that can each be cracked by frequency analysis. Longer, random keys make this harder, and a truly random key as long as the message (a one-time pad) cannot be broken this way — but a short memorable keyword like LEMON offers little protection against a computer. Enjoy it for puzzles, geocaches and classroom work.
Related: Atbash cipher · A1Z26 letter-to-number cipher.
Decrypting step by step
To read LXFOPVEFRNHR with the key LEMON, line the key up under the ciphertext again and subtract each key shift: L − L (11 − 11) = 0 = A, X − E (23 − 4) = 19 = T, F − M (5 − 12 = −7, plus 26 = 19) = T, and so on, recovering ATTACKATDAWN. In the tool, paste the ciphertext into the lower box and type the key — decryption happens as you type.
Variants you may meet
- Autokey. Britannica notes that Vigenère himself proposed following a short keyword with the plaintext itself, so the key never repeats. This tool implements the standard repeating-key cipher, not the autokey version.
- Running key. A long passage from a book is used as the key instead of a short word.
- Five-letter groups. Puzzle and historical ciphertexts often remove spaces and write the letters in blocks of five to hide word lengths.