QuirkText

Vigenere Cipher

The Vigenere cipher shifts each letter by a different amount, set by the letters of a repeating keyword. Enter text and a keyword to encrypt or decrypt, and watch each step in the table.

Mode
Result
Step by step
Vigenere square (tabula recta)

The highlighted cell is the first letter of your text: the row is the key letter, the column is the plain letter.

Runs entirely in your browser. Your data never leaves your device.

How to use it

  1. Choose Encrypt or Decrypt. The sample is "Attack at dawn!" with the keyword LEMON.
  2. Type a keyword made of letters. Spaces, digits and symbols in the keyword are ignored.
  3. Enter your text. Only letters use up a key letter, so spaces and punctuation stay in place and do not move the key.
  4. Read the result, tick Group in fives for classic ciphertext blocks, and open Step by step or the tabula recta to check any letter.

How the Vigenere cipher works

The Vigenere cipher is a stack of Caesar ciphers. You pick a keyword. Each letter of the keyword gives a shift: A is 0, B is 1, and so on up to Z, which is 25. You shift the first plain letter by the first key letter, the second by the second, and when the keyword runs out you start it again.

Because the shift changes, the same plain letter does not always give the same cipher letter. In the example below, the three Ts come out as X, F and F, and the four As come out as L, O, E and N. That breaks the simple letter counting that defeats a Caesar cipher.

Vigenere cipher formula

Number the letters A=0 to Z=25. With P the plain letter, C the cipher letter and K the current key letter:

encrypt: C = (P + K) mod 26
decrypt: P = (C - K) mod 26

Only letters use up a key letter. This tool skips spaces, digits and punctuation and does not advance the key for them. Many other tools and textbooks do the same, but a few do not, so when a decode fails, check this first.

Worked example: "Attack at dawn" with the key LEMON

The key letters are L=11, E=4, M=12, O=14, N=13. Write the key under the letters of the text and repeat it:

PlainATTACKATDAWN
KeyLEMONLEMONLE
Shift114121413114121413114
CipherLXFOPVEFRNHR

Check a few by hand. A (0) + 11 = 11, which is L. T (19) + 4 = 23, which is X. T (19) + 12 = 31, and 31 mod 26 = 5, which is F. K (10) + 11 = 21, which is V.

The ciphertext is LXFOPVEFRNHR, or Lxfopv ef rnhr if you keep the spaces and case, as the tool does. Tick Group in fives and you get LXFOP VEFRN HR.

The tabula recta

You can do the same job without arithmetic. The tabula recta is a 26 by 26 square. Row one is the alphabet from A. Row two starts at B, row three at C, and so on. To encrypt, find the row for the key letter and the column for the plain letter. The cell where they cross is the cipher letter.

For A with key L, go to row L and column A. The cell holds L. The square is shown in a collapsible panel under the tool, with your first letter highlighted. To decrypt, go to the key row, find the cipher letter in it, and read the heading of its column.

How to decrypt a Vigenere cipher

When you know the key

Choose Decrypt, enter the keyword and paste the ciphertext. Each letter moves backward by its key letter. For L under key L, 11 - 11 = 0, which is A.

When you do not know the key

This is the hard case, and the tool does not guess for you. The usual route has three steps:

  1. Find the key length.
  2. Split the text into that many columns, so that every column was shifted by one key letter.
  3. Solve each column as a Caesar cipher by frequency analysis.

Breaking it: Kasiski and Friedman

The Kasiski examination looks for repeated groups of letters in the ciphertext. If the same word appears twice in the plain text, and the gap between the two is a multiple of the key length, the key lines up the same way both times and the cipher text repeats. The gaps between repeats are then multiples of the key length, so their common factors point to it. Friedrich Kasiski published this in 1863. Wikipedia notes that Charles Babbage seems to have found it earlier, possibly by 1846.

A small demonstration: encrypt THEBOYTHEGIRL with the key KEY (length 3). You get DLCLSWDLCQMPV. The block DLC appears at position 0 and position 6. The gap is 6, a multiple of 3.

The Friedman test, from the 1920s, uses the index of coincidence. English text scores about 0.067. Uniformly random letters score about 0.0385. A correct column split gives values near English, and a wrong one stays near random, which tells you the key length.

How many keys are there?

Key lengthPossible keys (26 to the power of the length)
126 (a Caesar cipher)
4456,976
511,881,376
6308,915,776
8208,827,064,576

Those numbers look large, but the attack above never tries them all. It solves one column at a time, so a key of length 8 costs about 8 times 26 guesses, not 26 to the 8th.

Common mistakes

  • Advancing the key on spaces. Key letters belong to letters only. If your hand result differs from the tool, check whether you counted spaces.
  • Mixing up A=0 and A=1. A key letter A means shift 0, so the plain letter does not change. Use 0 to 25.
  • Wrong direction when decrypting. Subtract the key, do not add it.
  • Typing a key with digits or symbols. They are stripped out. The key "L3M0N" becomes "LMN".
  • Reading a single-letter key as a polyalphabetic cipher. The key "L" is just a Caesar cipher with shift 11.

Variants

  • Autokey. The key is the keyword followed by the plain text itself, so it never repeats. Wikipedia credits Blaise de Vigenere with publishing this stronger cipher in 1586.
  • Running key. The key is a long passage from a book. It does not repeat, but it still has English patterns that an attacker can use.
  • One-time pad. Use a truly random key as long as the message and never use it twice, and the cipher is theoretically unbreakable. Here the strength comes from the key, not the method. Reuse or a short key brings back every weakness described above.

A short history

The idea of switching alphabets goes back to Leon Battista Alberti, who described a cipher disk around 1467. Johannes Trithemius introduced the tabula recta in his Polygraphia, finished in 1508 and published in 1518. In 1553 Giovan Battista Bellaso added the repeating keyword, which is the cipher we now call Vigenere.

The name is a mistake. In the 19th century the scheme was credited to Blaise de Vigenere, who actually published a better autokey cipher. The cipher resisted attack for about three centuries and was called "le chiffre indechiffrable". Lewis Carroll still called it unbreakable in 1868, five years after Kasiski had published his attack.

Related tools

Start with the Caesar cipher tool to see a single shift. The ROT13 and Atbash pages cover two fixed substitutions, and Base64 decode handles an encoding, not a cipher.

Sources

Checked October 2026.

Frequently asked questions

What is the Vigenere cipher?

It is a polyalphabetic cipher: a Caesar cipher whose shift changes with every letter. A keyword such as LEMON gives the shifts 11, 4, 12, 14, 13, repeating. The same plain letter can therefore become different cipher letters.

How do I decrypt a Vigenere cipher with a key?

Switch to Decrypt, enter the same keyword and paste the ciphertext. Each letter is shifted backward by its key letter. By hand, find the key letter row in the tabula recta, locate the cipher letter in that row, and read the column heading.

How do I decrypt a Vigenere cipher without the key?

First estimate the key length with the Kasiski examination or the Friedman test. Then split the text into that many columns, and solve each column as a Caesar cipher with frequency analysis. This tool needs the key, it does not guess it.

What is the Vigenere formula?

Number the letters A=0 to Z=25. Encrypt with C = (P + K) mod 26 and decrypt with P = (C - K) mod 26, where K is the value of the current key letter. For A+L, 0 + 11 = 11, which is L.

What is the tabula recta?

It is a 26 by 26 square where each row is the alphabet shifted one place more than the row above. To encrypt, take the row of the key letter and the column of the plain letter, and read the cell where they meet. The tool shows it under the result.

Who invented the Vigenere cipher?

Giovan Battista Bellaso described it in 1553. It was later credited to Blaise de Vigenere by mistake, and the name stuck. Vigenere himself published a stronger autokey cipher in 1586.

Is the Vigenere cipher secure?

Not by modern standards. Friedrich Kasiski published a general attack in 1863, and a short or repeated keyword leaves patterns that can be found. It is much stronger than ROT13 or Atbash, but use it for puzzles, not for private data.

What does "Group in fives" do?

It strips everything except letters, converts them to uppercase and splits the output into blocks of five, like traditional ciphertext. This hides word lengths, which would otherwise help an attacker. It is for display, so decrypt the ungrouped text.