What Is the Vigenère Cipher?
The Vigenère cipher is a method of encrypting text with a keyword in which the shift applied to each letter changes as you move through the message. It belongs to the family of polyalphabetic substitution ciphers, because it uses not one but many substitution alphabets, selected in turn by the key. The first version was described by Giovan Battista Bellaso in 1553; Blaise de Vigenère published a more general form in 1586, and the cipher has carried his name ever since.
Its historical importance is hard to overstate. For roughly three hundred years the Vigenère cipher was regarded as practically unbreakable — "le chiffre indéchiffrable," the indecipherable cipher. It resisted the frequency-analysis techniques that had long since demolished simpler ciphers, because the same plaintext letter can encrypt to different ciphertext letters depending on where it falls in the message. It was not until the mid-1800s that Charles Babbage (in 1854, unpublished) and Friedrich Kasiski (in 1863, published) independently found systematic ways to break it, and those methods are the direct ancestors of the statistical cryptanalysis used today.
How the Vigenère Cipher Works
The cipher is best understood as a sequence of Caesar ciphers. Write the key repeatedly under the message, letter by letter (ignoring non-letters), then for each position add the plaintext letter and the key letter together modulo 26:
| Operation | Formula | Meaning |
|---|---|---|
| Encrypt | Cᵢ = (Pᵢ + Kᵢ) mod 26 | Add the key letter to each plaintext letter |
| Decrypt | Pᵢ = (Cᵢ − Kᵢ) mod 26 | Subtract the key letter from each ciphertext letter |
Here Kᵢ is the value of the key letter at position i (A = 0, B = 1, …, Z = 25), and "mod 26" wraps the result around the alphabet. When the message is longer than the key, the key simply starts over — a repetition that would eventually become the cipher's undoing. Non-letter characters are not encrypted and, importantly, do not consume a key position, so the key only advances over actual letters.
The Tabula Recta
Before computers, users applied the cipher with the tabula recta, a 26×26 table invented by Johannes Trithemius in the early 1500s. Row 0 is the alphabet in order; each row below it is shifted one position further left. To encrypt, find the plaintext letter's column and the key letter's row — their intersection is the ciphertext letter. To decrypt, find the ciphertext letter inside the key letter's row and read back up to the column header. The arithmetic in this tool is exactly the same operation, just without the paper.
Step-by-Step Example
The classic worked example encrypts "ATTACKATDAWN" with the key "LEMON". First write the key underneath, repeating it as needed:
| 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 |
| Value | 11 | 4 | 12 | 14 | 13 | 11 | 4 | 12 | 14 | 13 | 11 | 4 |
| Ciphertext | L | X | F | O | P | V | E | F | R | N | H | R |
Take the first pair: A (0) plus L (11) equals 11, which is L. Then T (19) plus E (4) equals 23, which
is X. Then T (19) plus M (12) equals 31, which wraps to 5, an F. Continuing produces
LXFOPVEFRNHR — the famous example from every cryptography textbook. Enter it in the
tool above with key LEMON to watch it decrypt back to ATTACKATDAWN.
Why "Indecipherable" Didn't Last
The cipher's fatal flaw is that the key eventually repeats. Modern breaking methods come in two steps. First, find the key length: the Kasiski examination looks for repeated strings in the ciphertext — repeated plaintext fragments (like "the") encrypted with the same key segment produce identical ciphertext fragments whose spacing reveals multiples of the key length. Alternatively, Friedman's index of coincidence measures the ciphertext's letter distribution statistically to estimate the key length. Second, once the length is known, take every k-th character as its own stream — each is a simple Caesar cipher with a fixed shift, and ordinary frequency analysis recovers each key letter. That two-step recipe works on any repeating-key cipher, which is why modern systems never reuse a key pattern and use ciphers like AES instead.
Ironically, Vigenère himself had also described an autokey variant in which the key extends itself with the plaintext instead of repeating — that version resists Kasiski-style attacks far better — but it was forgotten, and the repeating-key version carried his name into history.
Variants and Modern Relevance
Several close relatives share the Vigenère machinery. The Beaufort cipher encrypts as C = K − P and has the convenient property that encryption and decryption are identical. The autokey cipher extends the key with the message itself, eliminating the repetition weakness. A running key uses a long text (a book passage, say) as the key, which defeats periodicity at the cost of unwieldy key management. Wheatstone and Playfair took a different route entirely, encrypting letter pairs through a keyed square — you can try it on our Playfair Cipher Encoder & Decoder. None are used for modern security, but all of them — and the methods used to break them — remain the standard teaching material for how cryptanalysis works, and the cipher is a staple of puzzles, escape rooms, and capture-the-flag games.
Example Reference Table
| Plain Text | Key | Ciphertext |
|---|---|---|
| ATTACKATDAWN | LEMON | LXFOPVEFRNHR |
| hello | KEY | rijvs |
| Hello, World! | KEY | Rijvs, Uyvjn! |
| SimplyCalculated | TEAL | LmmaecCleguwtxeo |
Paste any plain-text value and its key into the tool to confirm the ciphertext matches, or paste ciphertext with the key to confirm it decodes back. Notice in the third row that spaces and punctuation survive untouched while only letters change.
Troubleshooting & Common Mistakes
My ciphertext will not decrypt back to my original text
Almost always a key mismatch: encryption and decryption must use the same key, letter for letter. Because only letters in the key count, "lemon" and "LEMON" are equivalent, but "lemons" is a different key entirely. Also check that the message was not altered in transit — a single changed letter produces exactly one wrong character on decrypt, which is a useful way to verify the key.
Why did my text come back with different capitalization?
Case is preserved position by position: the ciphertext "Rijvs, Uyvjn!" decrypts to "Hello, World!" with the exact original capitalization. If your result differs, the key letters used for those positions differ — revisit the key.
Can I encrypt numbers and symbols?
The classic Vigenère cipher only transforms A–Z letters; digits and symbols pass through unchanged (and, as always, do not advance the key). If you need to encrypt digits too, combine Vigenère with a second cipher that handles the rest of the character set.
Does a longer key make it more secure?
Against casual readers, yes — and against the classical attacks, a longer key is genuinely harder to crack. But because the key still repeats, it remains breakable by the two-step Kasiski/Friedman method no matter how long it is. Nothing in this family reaches modern cryptographic strength.
How This Cipher Compares to Other Classical Ciphers
Vigenère is one of several classical ciphers covered on this site — its polyalphabetic keyword approach is what let it outlast the single-shift Caesar cipher for centuries. The table below lines up its mechanism against the others, including the closely related Beaufort cipher.
| Cipher | Mechanism | What Makes It Different |
|---|---|---|
| Caesar Cipher | Substitution | Shifts every letter by one fixed number (the key) through the alphabet — the simplest classical substitution cipher. |
| Atbash Cipher | Substitution (fixed) | A special case of substitution with no key at all — it always mirrors the alphabet (A↔Z, B↔Y, ...). |
| Vigenère Cipher (this page) | Polyalphabetic substitution | Repeats a keyword to shift each letter by a different amount, defeating simple frequency analysis that breaks Caesar. |
| Beaufort Cipher | Polyalphabetic substitution (reciprocal) | A variant of Vigenère's idea that is self-reciprocal — the same operation both encrypts and decrypts. |
| Playfair Cipher | Digraph substitution | Encrypts letters two at a time using their positions in a 5×5 key square — the first practical digraph cipher (1854). |
| Affine Cipher | Mathematical substitution | Encrypts using a linear function (ax + b mod 26) with two keys instead of one shift value. |
| ROT47 | Substitution (extended range) | Applies a Caesar-style shift across the full printable ASCII range, not just letters — used to obfuscate text online (e.g. spoilers), not for security. |
| Rail Fence Cipher | Transposition | Rearranges letter order in a zigzag pattern instead of substituting letters — a fundamentally different technique from every cipher above. |
| A1Z26 | Encoding (not a cipher) | Simply maps each letter to its position number (A=1...Z=26) — a puzzle/encoding convention, not intended for real secrecy. |
| NATO Phonetic Alphabet | Encoding (not a cipher) | Replaces each letter with a spoken code word (Alfa, Bravo, Charlie…) for reliable voice transmission on noisy radios — built for clarity, not secrecy. |