Ciphers & codes

Vigenère cipher – explained and cracked

For three centuries the Vigenère cipher was considered unbreakable. It uses a keyword and shifts every letter differently. Here is how it works, how to do it by hand with the Vigenère square – and how it is cracked anyway.

Enter a keyword, type your text – with a step-by-step view of plaintext, key and ciphertext.

Open the Vigenère tool

How the Vigenère cipher works

The Vigenère cipher is a Caesar cipher with a changing shift. A keyword is written under the text again and again until every letter has a partner. Each key letter sets the shift: A = 0, B = 1, C = 2 … Z = 25.

Plaintext:  ATTACKATDAWN
Key:        LEMONLEMONLE
Ciphertext: LXFOPVEFRNHR

The first A is shifted by 11 with L and becomes L, the T is shifted by 4 with E and becomes X – and so on. Identical plaintext letters turn into different ciphertext letters: the two T’s in “ATTACK” become X and F. That is exactly what makes simple frequency analysis useless.

As a formula: cipher = (plain + key) mod 26, and to decrypt plain = (cipher − key) mod 26. Spaces and punctuation get no key letter.

The Vigenère square (tabula recta)

By hand you use the Vigenère square: row = key letter, column = plaintext letter, and the ciphertext letter sits where they meet. To decrypt, find the ciphertext letter in the key letter’s row – the column heading is the plaintext.

ABCDEFGHIJKLMNOPQRSTUVWXYZ
AABCDEFGHIJKLMNOPQRSTUVWXYZ
BBCDEFGHIJKLMNOPQRSTUVWXYZA
CCDEFGHIJKLMNOPQRSTUVWXYZAB
DDEFGHIJKLMNOPQRSTUVWXYZABC
EEFGHIJKLMNOPQRSTUVWXYZABCD
FFGHIJKLMNOPQRSTUVWXYZABCDE
GGHIJKLMNOPQRSTUVWXYZABCDEF
HHIJKLMNOPQRSTUVWXYZABCDEFG
IIJKLMNOPQRSTUVWXYZABCDEFGH
JJKLMNOPQRSTUVWXYZABCDEFGHI
KKLMNOPQRSTUVWXYZABCDEFGHIJ
LLMNOPQRSTUVWXYZABCDEFGHIJK
MMNOPQRSTUVWXYZABCDEFGHIJKL
NNOPQRSTUVWXYZABCDEFGHIJKLM
OOPQRSTUVWXYZABCDEFGHIJKLMN
PPQRSTUVWXYZABCDEFGHIJKLMNO
QQRSTUVWXYZABCDEFGHIJKLMNOP
RRSTUVWXYZABCDEFGHIJKLMNOPQ
SSTUVWXYZABCDEFGHIJKLMNOPQR
TTUVWXYZABCDEFGHIJKLMNOPQRS
UUVWXYZABCDEFGHIJKLMNOPQRST
VVWXYZABCDEFGHIJKLMNOPQRSTU
WWXYZABCDEFGHIJKLMNOPQRSTUV
XXYZABCDEFGHIJKLMNOPQRSTUVW
YYZABCDEFGHIJKLMNOPQRSTUVWX
ZZABCDEFGHIJKLMNOPQRSTUVWXY

Pick a keyword and start – or let the tool crack a Vigenère text without the key.

History: “le chiffre indéchiffrable”

Giovan Battista Bellaso described the method in 1553. It was named after the Frenchman Blaise de Vigenère, who published a related, stronger variant (autokey) in 1586. For about 300 years the cipher was considered unbreakable. Charles Babbage broke it around 1854 but published nothing; in 1863 the Prussian officer Friedrich Kasiski was the first to describe the method publicly.

Related variants the tool also supports:

Cracking Vigenère in three steps

  1. Find the key length. Kasiski test: when letter sequences repeat in the ciphertext, their distance is often a multiple of the key length. More precise is William Friedman’s index of coincidence: split the text into as many columns as the key is long and each column looks like normal language again – English text has an index of about 0.066, evenly spread letters only 0.038.
  2. Crack each column like Caesar. Every column is encrypted with the same shift. Its most frequent letter usually stands for E – which gives you the key letter of that column.
  3. Read and refine. If the text makes sense, you have the key. With short texts a single letter is sometimes off.

The tool does all of this automatically when you choose “Crack”: it checks key lengths up to 20 with the index of coincidence, determines each key letter with a chi-squared test for English and German, and shows key and plaintext. From about 100 letters it works reliably.

Tip for tough puzzles: the longer and more random the keyword and the shorter the text, the harder it is to crack. If the key is as long as the text and truly random, the cipher is even provably secure – that is the one-time pad.

Encode and decode Vigenère online

With Beaufort and autokey, key letters shown step by step, automatic cracking and frequency analysis. Runs only in your browser.

FAQ

How does the Vigenère cipher work?

Each letter is shifted as in Caesar, but the shift changes: it comes from the matching letter of a repeating keyword (A = 0, B = 1 … Z = 25).

How do I decrypt Vigenère without the key?

First find the key length (Kasiski test or index of coincidence), then crack each column like a Caesar cipher with frequency analysis. The tool’s “Crack” button does this automatically.

How long does the text need to be to crack it?

As a rule of thumb about 100 letters, more for long keywords. The more text per key letter, the more reliable the frequency analysis.

What is the difference from Caesar?

Caesar shifts every letter by the same amount; Vigenère changes the shift with each letter of the keyword. Caesar is a Vigenère cipher with a one-letter key.

Is Vigenère still secure today?

No. How to break it has been public since 1863. For real secrets, AES with a strong password is the right choice.

Sources

  1. Vigenère cipher – Wikipedia.
  2. Friedrich W. Kasiski: Die Geheimschriften und die Dechiffrir-Kunst, Berlin 1863.
  3. Index of coincidence (William F. Friedman) – Wikipedia.

Encode, decode or crack Vigenère online – free.

Open the tool