Vigenère Cipher

Encrypt and decrypt text with a Vigenère keyword cipher.

The Vigenère cipher uses a keyword to shift each letter by a different amount, which made it far harder to break than a Caesar cipher and earned it the nickname "the indecipherable cipher" for centuries. Today it's a classic for puzzles and classrooms, though frequency analysis breaks it.

How to use it

  1. Type your text.
  2. Enter a key made of letters.
  3. Choose encrypt or decrypt.
  4. Copy the result.

When it helps

  • Solving cipher puzzles.
  • Teaching polyalphabetic ciphers.
  • Writing clues for games.
  • Playing with classical cryptography.

Good to know

  • Only letters change, and the key advances only on letters.
  • Longer, less guessable keys are harder to break.
  • ATTACKATDAWN with key LEMON gives LXFOPVEFRNHR, a standard test case.

How the cipher works

Write the key letters repeatedly under the message. Each message letter is shifted along the alphabet by the position of the matching key letter, with A as 0 shift. For ATTACKATDAWN with key LEMON, the first letter A is shifted by L (11) to become L, and the second T by E (4) to become X.

Decryption subtracts the shifts.

Worked example

Message ATTACKATDAWN, key LEMON. Repeat the key: LEMONLEMONLE. Shift each letter: A+L=L, T+E=X, T+M=F, A+O=O, C+N=P, K+L=V, A+E=E, T+M=F, D+O=R, A+N=N, W+L=H, N+E=R. The ciphertext is LXFOPVEFRNHR.

Enter that ciphertext with the same key and choose Decrypt to get the message back.

How it was broken

For centuries the cipher was thought unbreakable, until Friedrich Kasiski published a method in 1863 for finding the key length from repeated patterns. Once the length is known, each position can be attacked like a Caesar cipher with frequency analysis.

Charles Babbage had found the same method earlier, but didn't publish it.

Uses today

It's a teaching tool, a puzzle staple and a mild way to hide spoilers. With a key as long as the message, never reused and random, it becomes a one-time pad, the only provably unbreakable cipher, but that needs a secure way to share the key.

Don't use it for real secrets.

Choosing a good key

A longer key resists attack better, and a key that isn't a dictionary word is harder to guess. Avoid repeated letters, since they weaken the pattern. A key as long as the message gives the strongest result.

Try encrypting the same message with keys of different lengths to see how the ciphertext changes.

Cracking it by hand

Look for repeated groups of letters in the ciphertext, measure the distances between them, and find common factors. That suggests the key length. Split the text into that many columns and treat each as a Caesar cipher, using the most frequent letter as E.

It's a satisfying exercise, and the same logic Kasiski used.

Questions

What does the key do?

Each key letter sets the shift for the matching text letter, repeating as needed.

Is it secure?

Not by modern standards.