Vigenère Cipher
Encode and decode the Vigenère cipher with a keyword of your choice. Switch between the classic Vigenère, Autokey, and Beaufort variants, follow along on the interactive tabula recta, and copy, download, or share the result. Everything runs in your browser.
Classic Vigenère: the keyword repeats across the message, adding a different shift to each letter.
Enter text above to see the result here.
Tabula recta (Vigenère square)
Find your key letter in the left column and your plain letter along the top row; the cell where they meet is the ciphertext letter. Rows for the letters in your keyword are highlighted.
How to use Vigenère Cipher
- 1
Choose encode or decode
Pick Encode to turn plain text into ciphertext, or Decode to turn ciphertext back into plain text using the same keyword.
- 2
Pick a cipher variant
Choose the classic Vigenère, the stronger Autokey whose key never repeats, or the reciprocal Beaufort variant. A short hint under the keyword explains each one.
- 3
Enter your keyword
Type a keyword such as LEMON. Only the letters A to Z in the keyword are used, and it is repeated or extended automatically to match your message.
- 4
Type or paste your text
Enter your message and the cipher runs as you type. Letters are enciphered while spaces, digits, and punctuation pass through unchanged.
- 5
Copy, download, or share
Copy the result, download it as a text file, or share a link that reopens the tool with your exact keyword, text, and settings ready to go.
Understanding the Vigenère Cipher
What is the Vigenère cipher?
The Vigenère cipher is a polyalphabetic substitution cipher that encrypts text using a keyword. Instead of shifting every letter by the same fixed amount, as the Caesar cipher does, it uses each letter of the keyword to apply a different shift to each letter of the message, cycling through the keyword over and over. Because the same plain letter can become several different cipher letters depending on its position, the cipher hides the single-letter frequency pattern that makes simple ciphers so easy to break.
For roughly three centuries it was considered unbreakable, earning the French nickname le chiffre indéchiffrable, the indecipherable cipher. Today it is a favourite in puzzles, escape rooms, and capture-the-flag challenges, and a classic lesson in how a key strengthens a cipher.
How Vigenère encryption works
First you choose a keyword, such as LEMON. The keyword is repeated above the message so that every letter of the plaintext is paired with a letter of the key. Each key letter stands for a shift: A means shift by 0, B by 1, C by 2, and so on up to Z, which shifts by 25. To encrypt, you add each plaintext letter to its key letter and wrap around the alphabet; to decrypt, you subtract instead.
Only the letters A to Z are enciphered, and each keeps its uppercase or lowercase form. Spaces, digits, and punctuation pass through untouched and do not consume a key letter, so the key always stays lined up with the actual letters of the message.
Worked example: keyword LEMON
Take the phrase ATTACK AT DAWN and the keyword LEMON. Lining the repeated keyword up with the letters gives LEMONLEMONLE. Adding each plaintext letter to its key letter, A plus L is L, T plus E is X, T plus M is F, and so on, produces the ciphertext LXFOPVEFRNHR. Notice that the two letters T in ATTACK become different cipher letters, X and F, because they sit under different key letters. That is exactly what defeats simple frequency analysis.
To decode, you reverse the process with the same keyword, subtracting each key letter, or you read the tabula recta backwards. Without the keyword, the ciphertext gives almost nothing away.
The Vigenère formula and the tabula recta
If letters are numbered from 0 to 25, with A as 0 and Z as 25, encryption is C = (P + K) mod 26 and decryption is P = (C - K) mod 26, where P is the plaintext letter, K is the current key letter, and the mod 26 makes the alphabet wrap around. The same operation can be performed by hand using the tabula recta, a 26 by 26 grid of shifted alphabets. Find the key letter on the left and the plaintext letter along the top, and the cell where the row and column meet is the ciphertext letter.
Autokey and Beaufort variants
The Autokey variant fixes the main weakness of the standard cipher, the repeating key. After the keyword runs out, the key continues with the plaintext itself, so the running key never repeats and the cipher is much harder to attack. Decryption recovers the plaintext one letter at a time and feeds it back into the key stream.
The Beaufort variant uses the formula C = (K - P) mod 26. Because subtracting from the key is its own inverse, the same operation both encrypts and decrypts, which made it convenient for the cipher disks once used at sea. This tool supports all three so you can compare them on the same text and keyword.
How to break the Vigenère cipher
The cipher is broken in two stages. First you find the length of the keyword, classically with the Kasiski examination, which looks for repeated groups of letters in the ciphertext and measures the gaps between them, or with the Friedman test, which uses the index of coincidence. Once the key length is known, the ciphertext splits into that many columns, each enciphered with a single Caesar shift, and ordinary frequency analysis cracks each column separately.
This means a Vigenère cipher with a short key on a long message is quite breakable, which is why the strength of the cipher depends heavily on using a long, non-repeating key. The Autokey and one-time-pad ideas grew directly out of trying to remove that repetition.
A short history of the Vigenère cipher
The idea of using a keyword to switch between alphabets was first published by Giovan Battista Bellaso in 1553, building on the polyalphabetic tables of Johannes Trithemius and Leon Battista Alberti. The method was later misattributed to the French diplomat Blaise de Vigenère, whose name stuck even though his own work described the stronger Autokey version. The repeating-key cipher resisted cryptanalysts for centuries until Charles Babbage broke it privately in the 1850s and Friedrich Kasiski published a general method in 1863.
Is the Vigenère cipher secure?
Not by modern standards. Once the Kasiski and Friedman methods were published, any Vigenère cipher with a repeating key became breakable with patience and, today, instantly with a computer. Its real value now is educational and recreational: it is the clearest way to see how a key turns a trivial cipher into a much stronger one, and it remains a staple of puzzles and programming exercises. For genuine security, modern algorithms such as AES are used instead.
Frequently asked questions
What is the Vigenère cipher?
How is the Vigenère cipher different from the Caesar cipher?
What is the keyword, and how is it used?
Can you show a worked Vigenère example?
What is the tabula recta or Vigenère square?
What are the Autokey and Beaufort variants?
How do you break or crack a Vigenère cipher?
Why was the Vigenère cipher called indecipherable?
Who invented the Vigenère cipher?
Does it change numbers, spaces, or punctuation?
Is the Vigenère cipher secure?
Is my text uploaded to a server?
How do I write a Vigenère cipher in code?
Related tools
Keep going with these handy tools