Skip to main content

Vigenère Cipher

The Vigenère cipher shifts each letter by a different amount, set by a keyword. Type a message and a keyword to encode it, or switch the direction to decode a message when you know the keyword.

Plain textCipher text
Your translation appears here.Try:

How to use the Vigenère cipher tool

  1. Type your message in the box and a Keyword under it. The keyword can be any word; only its letters count.
  2. The coded message appears as you type. Press Copy to paste it anywhere.
  3. To decode, press the arrows between the two labels, paste the coded message and type the same keyword.

Capital letters stay capital, and anything that is not a letter A to Z stays as it is.

How the Vigenère cipher works

Take the classic example from Wikipedia: the message ATTACK AT DAWN and the keyword LEMON. Write the keyword again and again under the letters of the message:

  • Message: A T T A C K A T D A W N
  • Keyword: L E M O N L E M O N L E
  • Coded: L X F O P V E F R N H R

Each keyword letter is a Caesar shift. L is 11 places from A, so the first A moves 11 places to L. E is 4, so T moves to X. M is 12, so the next T moves to F. Decoding moves each letter back by the same amount.

The same plain letter can turn into different coded letters, and the two As at the start of ATTACK become L and O. That is what makes Vigenère much harder to break than a simple substitution cipher: counting the most common letter no longer points straight to E.

The Vigenère square

Before computers, people used a table called the tabula recta: 26 rows of the alphabet, each one shifted one place further than the row above. To encode, find the column of the message letter and the row of the keyword letter; the letter where they cross is the coded letter. The translator above does the same lookup for every letter.

History of the Vigenère cipher

The cipher was first described by Giovan Battista Bellaso in 1553. It is named after Blaise de Vigenère, a French diplomat, because in the 19th century it was wrongly credited to him. Vigenère described a related but stronger cipher in 1586.

For about 300 years it had a reputation as le chiffre indéchiffrable, the indecipherable cipher. Charles Babbage broke it in the 1850s without publishing, and Friedrich Kasiski published a general method in 1863. Both relied on the keyword repeating: repeated pieces of the message coded with the same part of the keyword give repeated pieces of cipher text, and the gaps between them reveal the keyword length.

For a single shift with no keyword, use the Caesar cipher decoder, which also tries every shift for you.

Frequently asked questions

How do I decode a Vigenère cipher?

Press the arrows between the two labels to switch to decoding, paste the coded message and type the keyword. Each letter is shifted back by the matching letter of the keyword. Without the keyword it is much harder: you would need to work out the keyword length first, for example with the Kasiski method.

How does the keyword work?

Each letter of the keyword stands for a shift: A is 0, B is 1, C is 2 and so on up to Z, 25. The keyword is repeated under the message, and each message letter is shifted by the keyword letter under it. With the keyword LEMON, the first letter shifts by 11, the second by 4, the third by 12, and then the pattern repeats.

Do spaces and punctuation use up keyword letters?

Not here. The keyword only moves on when a letter is encoded, so spaces, numbers and punctuation stay as they are and do not change the result. Some other tools count every character, so if a decoded message looks wrong, check how it was encoded.

Is the Vigenère cipher secure?

Not by modern standards. It resisted attack for about three centuries and was called the unbreakable cipher, but Charles Babbage and Friedrich Kasiski showed in the 19th century how to find the keyword length and break it. A random keyword as long as the message, used only once, is a different and genuinely secure system, the one-time pad.

Is a Vigenère cipher with a one-letter keyword a Caesar cipher?

Yes. With a one-letter keyword every letter gets the same shift, which is exactly a Caesar cipher. The keyword D, for example, gives a Caesar shift of 3.