Encoder with a key, and the whole tabula recta

Vigenère cipher decoder

Encode and decode the Vigenère cipher with any key. With the key LEMON, ATTACK AT DAWNbecomes LXFOPV EF RNHR, and returns to ATTACK AT DAWN with the same key. The tabula recta below is generated row by row by the Caesar cipher.

How to use it

  1. Type the text in the left box and the key in the field below the boxes. The key needs at least one letter; spaces and digits in it are ignored.

  2. Each letter of the text is shifted by the matching letter of the key, which repeats to the end. Spaces and punctuation pass through and use up no key letter.

  3. To decode, paste the message into the right box and give the same key. Without the key, a Vigenère text does not yield to simple brute force.

A Caesar cipher per letter

The Vigenère cipher is the Caesar cipher with a key in place of a number. Each letter of the key stands for a shift, A for zero and Z for 25, and the key repeats along the text. With a one-letter key it is exactly Caesar: the key A changes nothing, ATTACK, and the key D is a shift of three,DWWDFN. With LEMON, the first letter of the text moves by the value of L, the second by the value of E, and so on: the opening A of ATTACK AT DAWN becomesL, the T after it becomes X.

That is what makes it stronger than Caesar. In the Caesar cipher every A of the text becomes the same letter, and counting which letter appears most in the ciphertext gives the key away. In Vigenère the same A becomes different letters according to its position, and the simple count stops working. Spaces and punctuation pass through unchanged and consume no key letter, so the words of the ciphertext stand where the words of the text stood; a decoder that strips the spaces instead will disagree with this one, and the key is then applied to a different sequence of letters.

The weakness is the repetition. If the key has five letters, every fifth letter of the text was encoded with the same shift, and a phrase that repeats in the text tends to repeat in the ciphertext at a distance that is a multiple of five. Measuring those distances reveals the length of the key, and each position becomes a Caesar cipher that falls to the frequency count. That is the Kasiski method, and it ended the three centuries of fame as the unbreakable cipher.

The tabula recta

Twenty-six rows, each the alphabet shifted one place further. The row of the key letter crossed with the column of the text letter gives the cipher letter. The table is the package's output, generated by the Caesar shift; the first row is the alphabet and each following row is the one above moved along.

Tabula recta, 26 generated rows
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

Frequently asked

What is the difference between the Vigenère and the Caesar cipher?

Caesar shifts every letter by the same number. Vigenère uses a keyword, and each letter of the key gives the shift for one letter of the text: A shifts by nothing, B by one, and so on to Z. With the key LEMON, ATTACK AT DAWN becomes LXFOPV EF RNHR, while the Caesar cipher at three would give DWWDFN DW GDZQ.

What is the tabula recta?

The table of 26 rows in which each row is the alphabet shifted one place further than the one above. To encode a letter, find the row of the key letter and the column of the text letter; the crossing is the cipher letter. The table on this page is generated row by row by the Caesar shift, never typed.

Why was it called unbreakable?

Because the same letter of the text becomes different letters in the ciphertext depending on its position, which defeats the frequency count that breaks Caesar. It held for about three centuries: Charles Babbage is reported to have broken a variant around 1854 without publishing, and in 1863 Kasiski published a method that finds the length of the key from repetitions in the ciphertext. After that each position of the key is a Caesar cipher, and falls like one.

Who invented the cipher?

The earliest description is by Giovan Battista Bellaso in 1553. The name of Blaise de Vigenère became attached to it in the nineteenth century, by mistake, and never came off. Vigenère described a similar cipher, with an autokey.

How should I choose a key?

The longer and less predictable the better: a short key repeats many times and gives its length away to the Kasiski method. For a treasure hunt one word will do and the fun is finding out which. For protecting anything real, no key will do; the cipher dates from 1553.