Cipher guide
Vigenère Cipher: How It Works and How to Break It
The Vigenère cipher uses a keyword to apply a different Caesar shift to each letter. For centuries it was thought unbreakable. A repeating key leaves a pattern, and the pattern can be found.
How the Vigenère cipher works
Choose a keyword, such as LEMON. Write it repeatedly under the message. Each keyword letter is a shift: A is 0, B is 1, up to Z as 25. Shift each message letter by the number under it.
Message: 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 Cipher: L X F O P V E F R N H R
The first A is shifted by L (11 places) and becomes L. The first T is shifted by E (4 places) and becomes X. The same message letter can turn into different cipher letters, which is why simple letter counting stops working.
How to break it by hand
- Find the key length. Look for sequences of three or more letters that appear more than once. The distances between repeats are often multiples of the key length, so the common factors of those distances point to it. This is called the Kasiski method. The other way is the index of coincidence: split the text into columns for each possible length and see which length makes the columns look like English.
- Split into columns. With a key of length 5, letters 1, 6, 11 and so on were all shifted by the first key letter. Letters 2, 7, 12 and so on share the second. Each column is a Caesar cipher.
- Solve each column. Count the letters in a column. The most common one is probably E, which tells you the shift, and so the key letter.
- Read the key. The shifts spell the keyword. Decode the whole message with it.
A small example
Take the ciphertext LXFOPVEFRNHR with a key length of 5. The first column is the 1st, 6th and 11th letters: L, V and H. All three were shifted by the same key letter. Try L as the shift (11 places): moving back 11 places turns L into A, V into K and H into W. Those are letters 1, 6 and 11 of ATTACKATDAWN. Repeat for the other four columns and the key LEMON appears.
Real messages need more text than this, since a single column of three letters says little. That is why key-length guessing works best on texts of about 100 letters or more.
Try it on your own text
Paste the ciphertext into the solver, choose Vigenère, and it will guess the key length and suggest a key. See also the Caesar cipher guide, since every column of a Vigenère message is one.
Open the cipher solverQuestions
Common questions
- What is the difference between Caesar and Vigenère?
- A Caesar cipher uses one shift for the whole message. A Vigenère cipher uses a keyword, and each letter of the keyword gives a different shift for the matching letter of the message.
- How long does the text need to be to break it?
- About 100 letters is enough for a good attempt. Longer texts give more reliable results, and a very short text may not have enough letters per column to show the pattern.
- What does index of coincidence mean?
- It measures how likely two letters picked at random from a text are the same. English scores about 0.067. Random letters score about 0.038. A correct key length makes each column score near the English value.
- What if the key is as long as the message?
- Then there is no repeating pattern to find and the methods here do not work. A key that is truly random, used once, cannot be broken this way.