handy.moe

All tools / Hacker kit

A girl with a magnifying glass

Vigenère cipher and cracker

Encrypt and decrypt with a keyword, or crack a Vigenère message without the key. The cracker measures the index of coincidence to find the key length, then works out each key letter, and usually needs well under a second.

Runs in your browser. Nothing you type is sent anywhere.

How to use it

  1. Type your text and a key, choose Encrypt or Decrypt.
  2. To crack: paste the ciphertext into the text box and press Crack. Give it 100 letters or more.
  3. Pick a guess with Use this key. If you know the key length, choose it before cracking.

How it's cracked

Vigenère shifts each letter by a different key letter, repeating the key. For three centuries it was called le chiffre indéchiffrable. Then Charles Babbage (around 1854) and Friedrich Kasiski (1863) saw the weakness: the key repeats. Take every k-th letter of the ciphertext and, if k is the key length, you get a plain Caesar cipher whose letters keep English's uneven frequencies. That shows up as a high index of coincidence, the chart under the results. Each column is then solved like a Caesar cipher, and the key is polished until the text reads most like English.

We tested the cracker on passages from a public-domain book with keys of 3 to 14 letters, down to 92 letters of ciphertext.

Questions

How much text does the cracker need?

As a rule of thumb, at least 15 to 20 letters for every letter of the key. With 300 or more letters it rarely misses.

Why does it offer a key like LEMONLEMON?

It doesn't: keys that repeat themselves are folded back to the short key. If two guesses look alike, the top one scored better as English.

What are Beaufort and autokey?

Beaufort uses key minus plaintext instead of plus, so encrypting and decrypting are the same step. Autokey uses the key once and then the message itself, which stops the repeating pattern; the cracker doesn't handle autokey.