Cipher

Vigenere Cipher Encoder and Decoder

The Vigenere cipher uses a keyword to shift each letter by a different amount, which makes it harder to break by hand than a single Caesar shift. Enter your text and a key, then encrypt or decrypt.

vigenere.encode
Plain text
Cipher text

Wicd qc kx lysl

For centuries it was called the indecipherable cipher, until Babbage and Kasiski showed in the 1800s that the key can be recovered from the ciphertext alone. Try it live below; the keyword and message stay in your browser.

How the Vigenere Cipher works

The keyword is repeated across the length of the message. Each plaintext letter is shifted by the alphabet position of the matching key letter, so the same letter can encrypt differently depending on where it sits.

Decryption reverses each shift using the same key. A longer, less predictable key makes hand analysis harder, but it does not save the cipher: given enough ciphertext, the key length falls out of the repetition pattern and each position is then a plain Caesar shift.

Examples

HELLO key LEMON
SIXZB
Each letter shifts by a different amount.
ATTACK key KEY
KXRKGI
SIXZB key LEMON (decode)
HELLO

Break it without the key

The Vigenere cipher was called indecipherable for three centuries, until Charles Babbage and Friedrich Kasiski showed that the key can be recovered from the ciphertext alone. This runs that analysis and shows each step rather than only the answer.

Step 1: is it polyalphabetic at all?

The index of coincidence for the whole text is 0.0508. English sits near 0.067 and a completely flat distribution near 0.038. This sits well below English, so the same letter is being enciphered differently in different places. That is the signature of a polyalphabetic cipher.

Step 2: how long is the key?

Split the text into columns, one per key position. At the correct key length every column has been shifted by a single amount, so each column looks like ordinary English again and its index of coincidence jumps back up.

Index of coincidence for each candidate key length
Key lengthAverage IC per columnReading
20.0555Leaning English
30.0525Leaning English
40.0539Leaning English
5most likely0.0803Close to English
60.0616Close to English
70.0553Leaning English
80.0570Leaning English
90.0498Flat
100.0833Close to English
110.0539Leaning English
120.0585Leaning English

Step 3: corroborate with Kasiski

Kasiski examination looks for sequences that repeat in the ciphertext. A repeat usually means the same plaintext met the same part of the key, so the distance between the two is a multiple of the key length.

Repeated three-letter sequences and the gaps between them
SequenceDistance between repeats
ELQ170
HEP30
GSI15, 110
IFV70
FVR25, 45

Step 4: recover the key

At a key length of 5, each column is a plain Caesar shift, so each can be solved on its own by frequency analysis. Doing that column by column gives the key LEMON.

Decoded with that key

the treasure is buried under the old oak tree by the river where the two paths meet just beyond the broken wall and you should bring a lantern because the path is dark after sunset and the ground is uneven near the water

If a letter or two of the key looks wrong, that is the analysis being honest rather than broken. Each column is solved from its own letters alone, so a short column can land on the wrong shift. Fix the odd letter by hand once the rest of the text reads as English, and take the key back up to the translator at the top of this page. If the whole thing is nonsense, the key length is probably a multiple of the real one: try the next-highest scoring length in the table above.

History and origins

The method is named after Blaise de Vigenere, a 16th-century French diplomat, though a similar idea was described earlier by Giovan Battista Bellaso. It resisted casual code-breaking for around 300 years.

Charles Babbage and later Friedrich Kasiski found ways to break it in the 19th century by spotting the repeating key length. Even so, it remains a superb tool for understanding polyalphabetic encryption.

Frequently asked questions

What makes the Vigenere cipher stronger than Caesar?

Caesar uses one fixed shift, so the same letter always encodes the same way. Vigenere changes the shift for every position using a keyword, hiding the letter-frequency patterns that give Caesar away.

How do I decrypt a Vigenere cipher?

Enter the same keyword you used to encrypt, switch the tool to decode, and paste the ciphertext. Without the key, breaking it requires frequency analysis of the repeating pattern.

Does the key need to be a real word?

No. Any sequence of letters works as a key. Longer, more random keys are harder to crack; a key as long as the message is theoretically unbreakable.

Learn more

Go deeper on the ideas behind this tool.

Not sure this is the right tool?

If you have a message and you are not certain what it is, the cipher identifier reads the character set and the letter statistics and tells you which scheme it most likely uses, and why. It covers every code and cipher on this site.

Related translators