Converters & translators
Vigenère Cipher Decoder & Encoder
Encode and decode the Vigenère cipher (or Beaufort, autokey and Gronsfeld), or crack a message without the key: the tool finds the keyword for you.
Updated · Free, no sign-up
Try an example
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. Accented letters are written as plain ones first (é becomes e, ß becomes ss), so nothing slips through unencoded.
- 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.
Other ciphers in the family. The menu next to Encode and Decode switches between Vigenère, Beaufort, variant Beaufort, autokey and Gronsfeld (a number key). Each one encodes, decodes and has its own Step by step; the differences are explained further down.
Share it. Copy link to this gives a link that reopens the tool exactly as you see it: mode, cipher, key and text. Send as a secret message gives a link with the coded message but not the key: your friend sees “Someone sent you a coded message” and types the key you agreed on. Both keep everything after the # in the link, a part browsers never send to our server. Anyone who has a link can read what is in it, though, so for a secret message leave the key out of the link and pass it on another way. Hand-made links work too: #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 (open this example in the tool). 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. Open it in the tool.
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 a Caesar shift (0 to 25), which is why the Vigenère cipher is sometimes described as a set of Caesar ciphers taking turns.
In the tool, Step by step shows this square with the key letter’s row and the message letter’s column lit up, one letter at a time (tap any letter to jump to it), and Print the square prints a clean full-page copy for solving by hand.
How to crack a Vigenère cipher without the key
Trying every keyword by hand is hopeless: a five-letter keyword already has 26 × 26 × 26 × 26 × 26 = 11,881,376 possibilities, and each extra letter multiplies that by 26. 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 (try it yourself in the tool).
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 ordinary English text it is about 0.0667, the textbook figure (E, T and A make matches likely); in a jumble of evenly mixed letters it is 1 in 26, about 0.0385. (Counted over our dictionary’s word list instead of running text it comes out a little lower, 0.064, because little words like “the” count only once there.) 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 cipher letters appear twice, and the distance between them is a multiple of the key length. Chance repeats happen too, and every even distance is divisible by 2, so the useful question is which length divides more of the distances than chance would. These are the repeats in the museum message:
| Repeated group | At letters | Distance | Divisible by 5? |
|---|---|---|---|
| MVVD | 145 and 240 | 95 | yes (5 × 19) |
| BBX | 45 and 273 | 228 | no: a chance repeat |
| CMA | 82 and 262 | 180 | yes (5 × 36) |
| NKC | 114 and 119 | 5 | yes (5 × 1) |
| UPX | 123 and 278 | 155 | yes (5 × 31) |
Across all 7 distances in the message, 5 divides 6 of them, far more than the 1 in 5 you would expect by chance, so the Kasiski test also says: key length 5.
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.
The tool also reads the message as a Beaufort cipher (the same columns, mirrored) and as an autokey cipher, tries tens of thousands of real English words as the key when the message is short, and tells you which reading looks most like English. If none of them does, it says so instead of offering nonsense as an answer. You can help it with a key length, the key letters you already know (LE?ON) or a word you expect in the message.
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
Open in the tool with the keyword
Show the answer
THE PICNIC IS AT NOON (keyword SUN)
Puzzle 2 (Medium)
Keyword: GARDEN
ROFN YAJEI WLR ZHZUH SRONHV CUT
Open in the tool with the keyword
Show the answer
LOOK UNDER THE THIRD FLOWER POT (keyword GARDEN)
Puzzle 3 (Hard)
The keyword is the answer to this riddle: I have keys but open no locks, I have space but no room, and you can enter but never go inside.
DLC TDATHCLGQ ZAEGC ER NWDELQLR
Open in the tool (type the keyword yourself)
Show the answer
THE SPACESHIP LANDS AT MIDNIGHT (keyword KEYBOARD)
Crack it without the key: two challenges
No keyword this time. Use the method above with pencil and paper, or open each one in the tool and use Crack it. Both are long enough (188 and 168 letters) for the statistics to work.
Challenge 1: the lighthouse note
A Vigenère cipher with the spaces kept. The keyword is a real word.
AHV PZU SIXIHYVUJF YVLPVS ZVMT R OCKL IE UVV SOXCCFR BVGCIL HV WOEPSYFR. ZA SRZG KOAK UVV SADQ ALZT SF ZZA EMFFP UIXIH, VCEE XVVU TYF GVH IJ DOCT, BVDOLZE R TVZW TYBH EVBFEM VEPVDHJ PS JUWCS OLU HYLRV, XOZAIEH TFY A CJUYA TF HIZKE ZU VFTE.
Show the answer
Vigenère cipher, keyword HARBOR: “The old lighthouse keeper left a note in the logbook before he vanished. It says that the lamp must be lit every night, even when the sea is calm, because a ship that nobody expects is still out there, waiting for a light to guide it home.”
Challenge 2: the garden box
Harder: written in groups of five, so the spaces give nothing away, and it is not plain Vigenère but one of its relatives from the table below.
CVIHX DPESE GFTQS HZIRP EHIWF FHYWD WAUTV PSRHD WWDAY KAZOV TDLSY URPGL LDDYL WEAAQ KFMEN LCWHU GSHSA UXIWW JFLUG TTXHT ALBES EKFOF IAKVS DXUKE CVTHV WJFSE KMSKP DDLIT HYVPS CLSKV SBDYL DPEXA LIWYS UKS
Show the answer
Beaufort cipher, keyword WILLOW: “Under the third step of the garden stairs there is a tin box. Inside you will find a silver key, a map of the woods and a riddle. Solve the riddle before sunset and the key will open the gate behind the old oak tree.”
Beaufort, autokey and the rest of the Vigenère family
All of these use the same 26 alphabets; they differ in which way the key is applied and where the key comes from. Letters count from A = 0 to Z = 25, and every sum wraps around (mod 26). Here is the same message, ATTACK AT DAWN, in each of them:
| Cipher | Encode / decode | Key | ATTACK AT DAWN becomes |
|---|---|---|---|
| Vigenère | C = P + K P = C − K | LEMON | LXFOPV EF RNHR |
| Beaufort | C = K − P P = K − C | LEMON | LLTOLB ET LNPR |
| Variant Beaufort | C = P − K P = C + K | LEMON | PPHMPZ WH PNLJ |
| Autokey | C = P + K P = C − K | LEMON | LXFOPK TM DCGN |
| Gronsfeld | C = P + K P = C − K | 31415 | DUXBHN BX EFZO |
Tap any result to open it in the tool, where Step by step shows each letter being worked out.
- Beaufort, named after Sir Francis Beaufort, the admiral behind the wind scale, takes the message letter away from the key letter. Because P = K − C has the same form as C = K − P, one step both encodes and decodes.
- Variant Beaufort is Vigenère turned around. A message encoded with it is cracked exactly like a Vigenère message; only the key comes out “negated” (LEMON shows up as PWOMN), which the tool spots when the negated key is a real word.
- Autokey uses the keyword once and then the message itself as the key, so the key never repeats and the key-length tests above find nothing. It still falls: every keyword letter starts its own chain of letters, and each chain can be solved from letter counts, which is how the tool cracks it.
- Gronsfeld is Vigenère with a number for a key. With shifts of only 0 to 9 it is weaker, and the key 31415 is the same as the Vigenère key DBEBF.
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 the early 1920s the American cryptologist William Friedman introduced 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.
- How do I use the Vigenère solver when I have the key?
- Choose Decode, pick the cipher (Vigenère unless you were told Beaufort, autokey or Gronsfeld), type the key and paste the code: the answer appears as you type. Step by step then shows every letter worked out, with its row and column in the Vigenère square, so you can check it by hand.
- 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 and the Kasiski test, works out each key letter from letter frequencies and shows the best keys. Plan on about 20 letters of code per key letter. Short messages also get real English words tried as the key, and if no reading looks like English the tool says so.
- What is the difference between the Beaufort and Vigenère ciphers?
- Both use the same square of 26 alphabets. Vigenère adds the key letter to the message letter (C = P + K); Beaufort takes the message letter away from the key letter (C = K − P), so the same step encodes and decodes. A third version, variant Beaufort, subtracts the key (C = P − K). The tool does all three and its cracker tries both Vigenère and Beaufort readings.
- What is an autokey cipher, and can it be cracked?
- An autokey cipher uses the keyword once and then continues the key with the message itself, so the key never repeats and the usual key-length tests find nothing. It can still be cracked: each keyword letter starts a chain of letters that can be solved from letter counts. Pick Autokey in the tool to encode or decode, and Crack it tries autokey automatically on messages of 40 letters or more.
- 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 square (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. Step by step in the tool highlights the row and column for every letter, and Print the square prints a clean copy for solving by hand.
- 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.
