What is the Vigenère cipher?
The Vigenère cipher encrypts text with a keyword instead of a single number. Each letter of the keyword stands for a shift (A is 0, B is 1, and so on), and the keyword repeats along the message. It is really several Caesar ciphers taking turns, which is why the same letter can come out differently each time. In the example above, the two Ts in ATTACK become X and F.
How to use this Vigenère cipher tool
- Type your keyword. Upper and lower case make no difference.
- Choose Encrypt or Decrypt.
- Type or paste your message. The result appears as you type.
- Click any letter in the rows to see its sum, and find the same spot marked on the table further down this page.
How to encrypt by hand: an example
Write the keyword under your message and repeat it until every letter has a key letter. Then shift each letter by its key letter.
| Text | A | T | T | A | C | K |
|---|---|---|---|---|---|---|
| Key | L | E | M | O | N | L |
| Result | L | X | F | O | P | V |
A with key L moves 11 places and becomes L. T with key E moves 4 places to X. Spaces and punctuation are copied across and do not use up a key letter, so ATTACK AT DAWN becomes LXFOPV EF RNHR.
How to decode a Vigenère cipher
With the keyword, decoding is the same process in reverse. Write the key under the coded text and shift each letter back by its key letter: L with key L goes back 11 places to A. In this tool, switch to Decrypt, enter the keyword and paste the coded text.
The Vigenère table
The Vigenère table, also called the Vigenère square or tabula recta, does the arithmetic for you. Each row is the alphabet shifted by one more place. To encrypt, go to the row of the key letter and the column of the text letter: the letter where they cross is the result. To decrypt, stay in the key letter’s row, find the coded letter, and read the letter at the top of its column. The letter you select in the tool is marked here, and the table follows the alphabet you choose.
| 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 |
The Vigenère cipher formula
Number the letters from A = 0 to Z = 25. P is a letter of the plain text, K its key letter and C the coded letter.
C = (P + K) mod 26
P = (C − K) mod 26 The third letter of ATTACK is T (19), and its key letter is M (12). 19 + 12 = 31, and 31 mod 26 = 5, which is F.
Can you break it without the key?
Yes, though this tool needs the keyword and will not find it for you. The usual attack has two steps. First find the key length: repeated groups of letters in the coded text tend to sit a multiple of the key length apart, a method known as the Kasiski examination. Then split the text into that many columns. Each column is a plain Caesar cipher, so counting its letters reveals the shift, and our frequency analysis tool can help with the counting. Short keys and long messages make this much easier.
Who invented the Vigenère cipher?
Not Vigenère, as it happens. The Italian Giovan Battista Bellaso published this method in 1553. The French diplomat Blaise de Vigenère described a stronger variant in 1586, and his name stuck to the simpler cipher later on. It earned the nickname “le chiffre indéchiffrable”, the indecipherable cipher, until Friedrich Kasiski published a general attack in 1863. Charles Babbage had broken it earlier but never published his work. Read about its relatives in our overview of substitution ciphers.
Frequently asked questions
What is the difference between the Caesar and Vigenère ciphers?
A Caesar cipher uses one shift for the whole message, while Vigenère changes the shift letter by letter. A one-letter keyword turns Vigenère into Caesar: the key D gives a shift of 3, so HELLO becomes KHOOR. The key N gives ROT13.
How long should the keyword be?
Longer is better, because a short key repeats often and leaves patterns in the coded text. Even so, the Vigenère cipher is for learning and puzzles, so never use it to protect passwords or private data.
What happens to numbers and spaces?
They stay as they are and the key does not advance on them. Only letters of the selected alphabet are shifted, and only they use up key letters.
Is my text sent to your server?
No. The tool on this page runs in your browser, so your text and keyword are not sent to our server.