Vigenère cipher

The Vigenère cipher encrypts each letter with a different Caesar shift, taken from a keyword. You write the keyword again and again under the message. Each key letter gives the shift for the letter above it: A = 0, B = 1, C = 2 and so on up to Z = 25.

Example with the keyword LEMON: the message ATTACKATDAWN is lined up with LEMONLEMONLE. A + L (11) gives L, T + E (4) gives X, T + M (12) gives F, and the whole message becomes LXFOPVEFRNHR. To decrypt, you subtract the key letters again. As a calculation: c = (p + ki) mod 26, where ki is the key letter at that position.

History

The method was described by Giovan Battista Bellaso in 1553 and later credited to the French diplomat Blaise de Vigenère, who wrote about a stronger variant in 1586. For about three centuries it had a reputation as “le chiffre indéchiffrable”, the unbreakable cipher. Charles Babbage broke it in the 1850s but did not publish his method; Friedrich Kasiski published a general attack in 1863.

Why it is stronger than Caesar

  • Many keys. A keyword of n letters gives 26n possible keys: almost 12 million for 5 letters.
  • Flattened frequencies. The same plain letter becomes different cipher letters depending on its position, so simple frequency analysis no longer works on the whole text.

How it is broken

The weak spot is that the keyword repeats. Repeated pieces of plaintext that happen to line up with the same part of the key give repeated pieces of ciphertext. The distance between them reveals the key length (the Kasiski examination). Once the length n is known, every n-th letter was encrypted with the same Caesar shift, and each of these groups can be broken with frequency analysis. If an attacker knows part of the plaintext, the key letters follow directly from k = c − p, a known-plaintext attack.

If the key is truly random, as long as the message and never used twice, there is no repetition to find. That is the one-time pad, which is provably secure but hard to use in practice.

Try it

Step through a message letter by letter with the Vigenère table in the projector mode. Teachers find a printable worksheet with answer key in the classroom area.

Searches the list of pages on this site. What you type stays in your browser.