Vigenère Cipher – Encode and Decode
Encrypt or decrypt text with the Vigenère cipher using any keyword. Choose standard, Beaufort or autokey, see the tabula recta and a step-by-step table, and watch long ciphertexts get broken automatically. Enter your message and key to start.
Turn Text into Ciphertext and Back — with Just a Keyword
Vigenère Cipher Formula
Where:
- \(C_i\) — the \(i\)-th ciphertext letter, written as a number: A = 0, B = 1, … Z = 25
- \(P_i\) — the \(i\)-th plaintext letter, same numbering
- \(K_i\) — the keystream letter, cycling through the keyword of length \(m\): \(K_i = k_{\,i \bmod m}\)
- \(\bmod\ 26\) — the alphabet wrap-around: after Z the count restarts at A
Each letter of the message is shifted by a different Caesar shift drawn from the keyword, which is exactly why the Vigenère cipher resisted analysis for three centuries while a single-shift Caesar cipher falls to simple frequency counting.
The Beaufort variant swaps the rule for \(C_i = (K_i - P_i + 26) \bmod 26\), which is its own inverse — the same formula encrypts and decrypts. The autokey variant stops repeating the keyword after \(m\) letters and continues the keystream with the message itself.
Vigenère Cipher – Calculation Example
Example: encrypt the message Attack at dawn! with the keyword LEMON, standard variant, keeping spaces and letter case (the default settings of this calculator).
Only letters are enciphered, so the keystream over the 12 letters is LEMONLEMONLE:
\[ \text{ATTACKATDAWN} + \text{LEMONLEMONLE} \;\to\; \text{LXFOPVEFRNHR} \]
The first three steps in numbers: A (0) + L (11) = 11 → L; T (19) + E (4) = 23 → X; T (19) + M (12) = 31 → 5 → F.
Result: Lxfopv efrnhr! — the space and the exclamation mark pass through unchanged and consume no key letters. Pasting this result back with Mode set to Decrypt returns the original message.
How to Use the Calculator
- Type or paste your message into Text to encrypt or decrypt.
- Enter a word in Key (keyword) — only its letters A–Z count, so "Lemon!" works exactly like LEMON.
- Set Mode: Encrypt turns plaintext into ciphertext, Decrypt reverses it.
- Pick a Variant: standard, Beaufort (same operation both ways) or autokey (the message itself continues the keystream after the keyword).
- Adjust the two checkboxes: Keep letter case copies the case of each input letter into the output; Keep spaces & punctuation lets non-letters through unchanged instead of dropping them.
- Read your result in the output box and copy it with one click — the tabula recta and the step table below show exactly how every letter was transformed.
- If your text holds 40 or more letters, the cryptanalysis section at the bottom automatically attempts to break it as a Vigenère ciphertext: it estimates the key length with the index of coincidence and Kasiski's test, then recovers the keyword by frequency analysis.
What Is the Vigenère Cipher?
The Vigenère cipher, published by Blaise de Vigenère in 1586 but built on the tabula recta printed by Johannes Trithemius in 1518, is a polyalphabetic cipher: instead of shifting every letter by the same amount, it shifts each letter by an amount taken from a repeating keyword. Consecutive occurrences of the same plaintext letter usually encrypt to different ciphertext letters, which masks the frequency fingerprints of natural language.
Mechanically it is nothing more than many Caesar ciphers run in parallel, one per keyword letter. The tabula recta shows this at a glance: each key letter selects one row of the 26×26 square, and enciphering a letter means reading the cell where its column meets that row. With the key LEMON, the cipher is five interleaved Caesar shifts of 11, 4, 12, 14 and 13 positions, cycling forever.
For nearly three centuries the scheme was called le chiffre indéchiffrable — the indecipherable cipher. It fell in the 19th century when Kasiski noticed that repeated chunks of plaintext, enciphered at matching positions in the key cycle, produce repeated ciphertext whose spacing reveals the key length; Friedman's index of coincidence then made that length measurable statistically. Once the length is known, the cipher splits into that many independent Caesar shifts, each broken by ordinary frequency analysis — the exact attack this calculator performs automatically on long texts.
Interpreting the result is simple: the output is ready to copy and send, and decrypting with the same key and variant always restores the original letters. If a decryption produces garbage, the most common causes are a wrong variant (a Beaufort-encrypted text will not decrypt in standard mode), a key typo, or different settings for spaces and punctuation.
Assumptions, Limitations and Practical Tips
- The keystream advances on letters only. Spaces and punctuation never consume key letters, so the same key always produces the same result regardless of formatting — but only when the Keep spaces & punctuation checkbox is used consistently on both sides.
- Key length is the whole security. A one-letter key is a plain Caesar cipher; a short or predictable keyword (a name, a date, a dictionary word) makes the cryptanalysis section's job easy. Long, random keywords resist casual breaking far longer.
- Never reuse a key between messages. Reused keystreams leak the period across messages and invite classical attacks, the way reused one-time pads do.
- The automatic attack has honest limits. It assumes a standard Vigenère ciphertext in English. Beaufort needs a preliminary reflection of the letters, and autokey ciphers have no repeating period at all, so the section does not apply to them. Below roughly 100 letters the true key length can lose the index-of-coincidence contest — if the recovered plaintext looks mostly right with a few wrong runs, try neighbouring key lengths.
- This is a learning tool, not a security tool. The Vigenère cipher is unbreakable to Victorians and transparent to any modern computer. For real protection of data, modern cryptography is the only option — hashing a password with the SHA-256 hash generator or creating keys with the password generator belongs to a different world than a 16th-century square.
- Everything runs locally. The message, the key and the cryptanalysis never leave your browser tab.
Related Tools
To shift the whole alphabet by a single fixed amount, use the Caesar cipher encoder and decoder. For other classic encodings, try the Morse code converter or the Base64 encoder.
Frequently Asked Questions
How do I encrypt text with the Vigenère cipher by hand?
Number every letter A = 0 through Z = 25, write your keyword repeatedly under the message, and add each pair of numbers modulo 26, converting the sum back to a letter. For example, H (7) + L (11) = 18 → S. Alternatively, use the tabula recta: find the plaintext letter on the top edge, follow that column down to the keyword's row, and read off the ciphertext letter. Spaces and punctuation are traditionally skipped — they never consume a key letter.
What is the difference between the Vigenère and the Caesar cipher?
A Caesar cipher shifts every letter by the same fixed amount, so the whole message is one shift — frequency analysis breaks it instantly. The Vigenère cipher applies a different shift to each position, taken from a repeating keyword, so it is really several Caesar ciphers interleaved. That is why the same plaintext letter usually encrypts to different letters, masking the frequency fingerprint that gives the Caesar cipher away. A one-letter keyword makes Vigenère collapse into plain Caesar.
How can I crack a Vigenère cipher without knowing the key?
The classical attack works in two steps. First find the key length: repeated plaintext chunks produce repeated ciphertext at distances that are multiples of the period (Kasiski's test), and splitting the text into every L-th letter makes those cosets look like normal English precisely when L is correct (index of coincidence). Then break each coset as an ordinary Caesar shift using frequency analysis. The calculator runs this whole attack automatically on texts with 40+ letters.
Why does my decryption produce gibberish?
Check three things in order. First, the variant: a Beaufort or autokey ciphertext will not decrypt in standard mode, so match the variant used for encryption. Second, the key: only letters count, so "L3MON" really means LMON and produces a completely different result. Third, the checkboxes: if one side kept spaces and punctuation and the other dropped them, the keystream lines up differently and letters after the first gap come out wrong.
What makes a good Vigenère keyword?
Long and random. Each extra key letter multiplies the work a codebreaker must do, and unpredictable sequences resist the dictionary-guessing that defeats words like CAT or names like ALICE. A one-letter key is just a Caesar cipher; a famous date like 1776 (GXYZG) is guessable; and reusing the same key across messages leaks its period. Be aware, though, that even a perfect keyword is broken by any modern computer — use this cipher for fun and learning, never for protecting real data.
Does the Vigenère cipher handle numbers, accented letters, or other alphabets?
The classic cipher works only on the 26 letters A–Z. Digits and punctuation pass through unchanged (or get dropped, depending on the settings), and accented characters like É or Ü are treated as non-letters, not mapped to E and U. The keystream advances on A–Z letters only, so the same message gives the same result regardless of formatting. For other writing systems you would need a separate alphabet-specific implementation, since the formula \( (P_i + K_i) \bmod 26 \) assumes 26 symbols.
What is the difference between the standard, Beaufort, and autokey variants?
The standard variant encrypts with \( C_i = (P_i + K_i) \bmod 26 \) and decrypts by subtracting the key. The Beaufort variant uses \( C_i = (K_i - P_i) \bmod 26 \), which is its own inverse — the identical operation both encrypts and decrypts. The autokey variant abandons the repeating keyword: after the initial keyword runs out, the message itself (plaintext when encrypting, ciphertext when decrypting) continues the keystream, removing the repeating period that Kasiski's attack exploits.