Converters & translators
Vigenère Cipher Decoder & Encoder
Encode and decode the Vigenère cipher with a keyword, or crack a message without the key: the tool finds the key length and the keyword for you.
Updated · Free, no sign-up
Share this tool
Know someone who’d love it?
What is the Vigenère cipher?
The Vigenère cipher encodes a message with a keyword. Each letter of the keyword stands for a Caesar shift (A = 0, B = 1 … Z = 25), and the keyword is repeated along the message so that every letter gets its own shift. Because the shift keeps changing, the same plain letter can turn into different cipher letters, and the simple tricks that break a Caesar cipher stop working. That is why it is called a polyalphabetic cipher: it uses several cipher alphabets instead of one.
For about three hundred years it had a reputation as unbreakable, and in French it was nicknamed le chiffre indéchiffrable, “the indecipherable cipher”. It is not, and the tool above shows how it is broken. The name is said “vee-zhuh-NAIR”, after the French writer Blaise de Vigenère.
How to use the Vigenère cipher decoder and encoder
- Choose Encode or Decode.
- Type the keyword. Only its letters count, so “Lemon”, “LEMON” and “le mon” are the same key.
- Type or paste the message. The result updates as you type. Spaces, digits and punctuation are copied as they are and do not use up a key letter, which is how most puzzles and textbooks do it.
- Copy the result, or press Decode this to check it decodes back.
Don’t know the key? Open Crack it: I don’t know the key. The tool measures which key length fits the message best, works out each letter of the keyword, and lists the best keys with a preview of each. Press Use this key, and if a letter or two is still wrong, correct it in the Keyword box; the decoded text updates as you type. The Step by step section lines the keyword up under your message and shows the rows of the Vigenère square it uses, and Letter frequencies shows how flat the letter counts of a Vigenère message are.
Links can open the tool filled in: ?text=LXFOPV&key=LEMON&mode=decode decodes straight away, and &open=crack opens the cracker.
Vigenère cipher table
How to encode a Vigenère cipher by hand
Write the keyword under the message letter by letter, repeating it as often as needed and skipping spaces. Shift each message letter forward by the value of the key letter under it. Here is the classic textbook example, ATTACK AT DAWN with the keyword LEMON:
| 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 |
| Shift | 11 | 4 | 12 | 14 | 13 | 11 | 4 | 12 | 14 | 13 | 11 | 4 |
| Cipher | L | X | F | O | P | V | E | F | R | N | H | R |
So ATTACK AT DAWN becomes LXFOPV EF RNHR. Look at the first letters: A under L is shifted by 11 and becomes L; the T under E is shifted by 4 and becomes X, but the very next T sits under M and becomes F. The doubled TT of ATTACK no longer looks doubled.
That is the whole point of the cipher. Encode EEEEEE with the key CAT and you get GEXGEX: one letter, 3 different disguises. In numbers the rule is C = (P + K) mod 26, where P is the message letter, K the key letter and A = 0.
How to decode a Vigenère cipher with the key
Line the keyword up under the code in the same way and shift each letter back by its key letter: P = (C − K) mod 26. With the keyword CASTLE, the message Oewm xi dy lap snd uezgm tgppv ct kxgip decodes to Meet me by the old clock tower at seven.
If the result starts well and turns into nonsense, the key and the message have slipped out of line, usually because a space or punctuation mark was counted on one side but not the other. This tool never spends a key letter on anything but a letter, so paste the code exactly as you received it.
The Vigenère table (tabula recta)
Before calculators, people used a 26 × 26 square of alphabets, each row shifted one place further than the one above. To encode, find the key letter at the left and the message letter along the top; the cipher letter is where that row and column meet. To decode, go along the key letter’s row until you find the cipher letter, and read the message letter at the top of that column.
| Key | A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| A | A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z |
| B | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z | A |
| C | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z | A | B |
| D | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z | A | B | C |
| E | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z | A | B | C | D |
| F | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z | A | B | C | D | E |
| G | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z | A | B | C | D | E | F |
| H | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z | A | B | C | D | E | F | G |
| I | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z | A | B | C | D | E | F | G | H |
| J | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z | A | B | C | D | E | F | G | H | I |
| K | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z | A | B | C | D | E | F | G | H | I | J |
| L | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z | A | B | C | D | E | F | G | H | I | J | K |
| M | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z | A | B | C | D | E | F | G | H | I | J | K | L |
| N | N | O | P | Q | R | S | T | U | V | W | X | Y | Z | A | B | C | D | E | F | G | H | I | J | K | L | M |
| O | O | P | Q | R | S | T | U | V | W | X | Y | Z | A | B | C | D | E | F | G | H | I | J | K | L | M | N |
| P | P | Q | R | S | T | U | V | W | X | Y | Z | A | B | C | D | E | F | G | H | I | J | K | L | M | N | O |
| Q | Q | R | S | T | U | V | W | X | Y | Z | A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P |
| R | R | S | T | U | V | W | X | Y | Z | A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q |
| S | S | T | U | V | W | X | Y | Z | A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R |
| T | T | U | V | W | X | Y | Z | A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S |
| U | U | V | W | X | Y | Z | A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T |
| V | V | W | X | Y | Z | A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U |
| W | W | X | Y | Z | A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V |
| X | X | Y | Z | A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W |
| Y | Y | Z | A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X |
| Z | Z | A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y |
Row A is the plain alphabet (a shift of 0), so a key letter A leaves its letter unchanged. Each row is one of the 25 Caesar shifts, which is why the Vigenère cipher is sometimes described as a set of Caesar ciphers taking turns.
How to crack a Vigenère cipher without the key
Trying every keyword is hopeless: a five-letter keyword already has 26 × 26 × 26 × 26 × 26 = 11,881,376 possibilities. The trick is to split the problem in two. Once you know how long the keyword is, every letter of the message that was encoded with the first key letter is a Caesar cipher, and so is every letter encoded with the second, and so on. Each of those is easy.
Here is how the cracker in the tool handled a 292-letter museum announcement encoded with a keyword we gave it no hint about.
Step 1: find the key length
Index of coincidence. Pick two letters of a text at random: how likely are they to be the same letter? In English it is about 0.064 by our dictionary count (E, T and A make matches likely); in a jumble of evenly mixed letters it is 1 in 26, about 0.038. The museum message had 0.063 before encoding and only 0.043 after: the keyword flattened the letter counts. Now split the code into columns (every 2nd letter, every 3rd letter and so on) and measure each column. When the number of columns matches the key length, each column is a single Caesar shift again and the score jumps back up toward English:
| Key length tried | Average index of coincidence of the columns |
|---|---|
| 1 | 0.043 |
| 2 | 0.043 |
| 3 | 0.043 |
| 4 | 0.041 |
| 5 (the real length) | 0.065 |
| 6 | 0.044 |
| 7 | 0.041 |
| 8 | 0.040 |
| 9 | 0.047 |
| 10 (a multiple of 5) | 0.067 |
| 11 | 0.034 |
| 12 | 0.042 |
Multiples of the real length score just as well, because their columns are single shifts too, so the cracker prefers the shortest length that scores high. The Kasiski test points the same way: when the same group of letters happens to be encoded with the same part of the key twice, the same three cipher letters appear twice, and the distance between them is a multiple of the key length. In this message, the distances between repeated three-letter groups were most often divisible by 5 (7 times), 2 (3 times), 3 (3 times).
Step 2: solve each column like a Caesar cipher
With the length known, take each column on its own and try all 26 shifts, keeping the one whose letter counts look most like English. Each column’s best shift is one letter of the keyword. The tool then double-checks every key letter against the whole message, trying all 26 options for each position and keeping whichever makes the most real English words.
For the museum message it found the keyword ORBIT, which is the key we used, and the decoded text begins: “The museum opens its new space gallery on Friday morning. Visitors will be able…”
When it struggles. The method needs enough letters in every column. As a rough guide, aim for twenty or more letters per key letter: a 5-letter key wants about 100 letters of code. Short messages, very long keywords and keys as long as the message (a one-time pad) defeat it. When the result is almost right, a wrong key letter shows up as every fifth (or sixth…) letter being off, and you can fix it by hand in the Keyword box.
Vigenère cipher examples to practice
Decode these with the keyword given, on paper or with the tool, then check the answers.
Puzzle 1 (Easy)
Keyword: SUN
LBR HCPFCP AM NL HBGH
Show the answer
THE PICNIC IS AT NOON (keyword SUN)
Puzzle 2 (Medium)
Keyword: GARDEN
ROFN YAJEI WLR ZHZUH SRONHV CUT
Show the answer
LOOK UNDER THE THIRD FLOWER POT (keyword GARDEN)
Puzzle 3 (Hard)
The keyword is the name of the planet we live on.
XHV LWECVLOMP CTUHS RM TMDEBNLT
Show the answer
THE SPACESHIP LANDS AT MIDNIGHT (keyword EARTH)
Related ciphers
- Caesar cipher: a Vigenère cipher with a one-letter keyword. Keyword D is a Caesar shift of 3.
- Autokey cipher: the keyword is used once and then the message itself continues the key, so the key never repeats and the key-length attack above does not apply. This is the cipher Blaise de Vigenère actually described.
- Beaufort cipher: uses the same square but subtracts the message letter from the key letter (C = K − P), so encoding and decoding are the same step.
- Gronsfeld cipher: a Vigenère cipher whose key is a number, each digit giving a shift from 0 to 9.
- One-time pad: a Vigenère-style cipher with a truly random key as long as the message, used only once. Used correctly, it cannot be broken at all.
For single-alphabet ciphers, see the Substitution Cipher solver and the Affine cipher.
History of the Vigenère cipher
The cipher is named after the wrong person. It was first described by the Italian Giovan Battista Bellaso in a booklet of 1553. Blaise de Vigenère, a French diplomat, published his book on ciphers in 1586 and described a stronger relative, the autokey cipher; in the nineteenth century the simpler repeating-key version became attached to his name, and it stuck.
Its reputation lasted until the 1800s. Charles Babbage, the English mathematician, is known to have broken Vigenère messages in the 1850s but did not publish his method. In 1863 the Prussian officer Friedrich Kasiski published the attack that now carries his name. In 1922 the American cryptologist William Friedman published the index of coincidence, which turned finding the key length into simple arithmetic.
Tips for making a stronger Vigenère puzzle
- Use a longer keyword with no repeated pattern. A one-letter keyword is only a Caesar cipher, and AAAA is no cipher at all.
- Remove the spaces or write the code in groups of five, so word lengths give nothing away.
- Keep the message short compared with the keyword if you want it to resist the cracker; keep it long if you want solvers to be able to crack it.
- Hide the keyword in an earlier clue: a riddle, a word in a picture, or an A1Z26 number code.
Free and private
The Vigenère tool runs entirely in your browser: free, with no sign-up, and the messages and keys you type are not uploaded or stored.
For teachers, bloggers & clubs
Put the Vigenère Cipher on your website
Give your readers this tool right on your page. Copy the code, paste it into your site, done: no sign-up, no account.
- Free for any website
- No ads, no cookies
- Fits phones and sidebars
- Always up to date
Please keep the small credit line under the tool; you may add rel="nofollow" to its link. How it works & the rules
› Show the code
Frequently asked questions
- What is the Vigenère cipher?
- A cipher that uses a keyword to give each letter its own Caesar shift. The keyword repeats along the message, and each key letter (A = 0, B = 1 … Z = 25) says how far to shift the letter it sits under.
- How do I decode a Vigenère cipher with the key?
- Write the keyword under the code, repeating it and skipping spaces, and shift each letter back by its key letter. In the tool, choose Decode, type the keyword and paste the message.
- Can you decode a Vigenère cipher without the key?
- Yes, if the message is long enough. Open Crack it in the tool: it finds the key length with the index of coincidence, works out each key letter from letter frequencies and shows the best keys. Plan on about 20 letters of code per key letter.
- How do you find the key length of a Vigenère cipher?
- Split the code into columns for each possible length and measure how English-like each column's letter counts are (the index of coincidence). At the right length every column is a plain Caesar shift and the score jumps. Repeated letter groups (the Kasiski test) point to the same length.
- What is the Vigenère table?
- A 26 by 26 square of alphabets, each row shifted one place from the row above, also called the tabula recta. The key letter picks the row, the message letter picks the column, and the cipher letter is where they meet.
- How do you pronounce Vigenère?
- Roughly vee-zhuh-NAIR, after the sixteenth-century French writer Blaise de Vigenère.
- Who invented the Vigenère cipher?
- Giovan Battista Bellaso described it in 1553. Blaise de Vigenère published a stronger autokey cipher in 1586, and the repeating-key cipher later became known by his name.
- Is the Vigenère cipher secure?
- No. It was broken in the nineteenth century and a computer cracks a typical message in a fraction of a second. Only a truly random key as long as the message and never reused, a one-time pad, makes it unbreakable.
- Why do spaces and punctuation not change?
- The tool shifts letters only and does not use up a key letter on spaces, digits or punctuation, which is the usual convention. Paste a code exactly as you received it so the key stays lined up.
About this page
The Vigenère Cipher is a free tool from Linguaholic, made by Marcel Iseli. It runs in your browser, with no sign-up. Last updated .
The code breaker's English letter frequencies and word checks come from Linguaholic’s English dictionary, built from the open ENABLE and SCOWL word lists. Licenses and notices.
Keep exploring
More free tools
Caesar CipherShift letters to encode or decode, or crack a Caesar message without knowing the key.
Substitution CipherEncode with any alphabet or keyword, or crack a cryptogram and fix letters yourself.
Affine CipherEncode or decode with keys a and b, see the math, or crack it by trying all 312 keys.
ROT13Hide or reveal text with ROT13, or switch to ROT5, ROT18 or ROT47.
Atbash CipherMirror the alphabet (A↔Z, B↔Y) to encode or decode, with the full Atbash chart.
Morse Code TranslatorTranslate text to Morse code and back, hear it as sound at any speed, and see the full Morse alphabet chart.
