Key length
Index of coincidence
Recovered key
Letter
Cracking
Playback
View

More information about the Vigenère cipher and how to crack it

The Vigenère cipher, made and broken

For three hundred years the Vigenère cipher was called le chiffre indéchiffrable: a keyword gives every letter its own Caesar shift, so the letter frequencies that betray simple ciphers are smeared out. Watch a message being encrypted letter by letter on the tabula recta, then break it the way Charles Babbage and Friedrich Kasiski did: find the length of the key from repetitions and from the index of coincidence, and the key itself column by column. The Vigenère cipher shifts every letter of the message by a different amount: the letters of a keyword, written again and again under the message, say how far (A by 0, B by 1, … Z by 25). Type a message and a key, and press Play to watch it encrypted letter by letter on the tabula recta: the row of the key letter and the column of the plain letter meet at the cipher letter. The strips below keep plaintext, key and ciphertext lined up. Choose Decrypt to go back, Autokey to let the message itself continue the key, or Beaufort, which subtracts the plain letter from the key letter. Then crack it as Babbage and Kasiski did: Kasiski examination shows repeated trigrams in the ciphertext and how often each number divides their spacings; Index of coincidence shows for every key length how much the letters in each column agree, which peaks at the true length; Column frequencies decrypts each column with the Caesar shift that fits the language best and reads off the key. The cracking reads only the ciphertext typed so far, so play a long example and watch the key length appear. A key as long as the message (a one-time pad) or an autokey leaves nothing to find. Use as input swaps the result into the message box; Decrypt with the found key tries the recovered key. Click a letter in the strips to jump to it, or use the arrow keys. Save image, record a video with a typewriter click per letter, or open the picture in the photo editor with the pencil, where the table, the highlight, the strips and the chart are layers of their own.

Як це працює

  1. Press Play: ATTACK AT DAWN is encrypted with LEMON letter by letter, the row of each key letter and the column of each plain letter meeting at its cipher letter on the tabula recta, plaintext, key and ciphertext lined up in the strips.
  2. Type your own message and key, switch to Decrypt, or try Autokey, where the message continues the key, and Beaufort, which subtracts the letter from the key; the result box keeps the whole text to copy.
  3. Pick a long example and show Kasiski examination or Index of coincidence: as more ciphertext is typed, the repeated trigrams line up and the peak at the true key length rises out of the noise.
  4. Show Column frequencies to see every column decrypted with the Caesar shift that fits the language best: the shifts spell the key, which Decrypt with the found key then tries on the whole text.

A different Caesar shift for every letter

Number the letters A = 0 to Z = 25. The Vigenère cipher writes a keyword again and again under the message and adds each key letter to the letter above it, modulo 26: with the key LEMON, A + L gives L, T + E gives X, and ATTACK AT DAWN becomes LXFOPV EF RNHR. The same plain letter turns into different cipher letters, so the most common cipher letter is no longer simply E. To decrypt, subtract the key again. The tabula recta, a 26 × 26 square of shifted alphabets printed by Johannes Trithemius in 1508, does the arithmetic by eye: the row of the key letter and the column of the plain letter meet at the cipher letter.

Autokey and Beaufort

A short keyword repeats, and the repetition is the weakness. In 1586 Blaise de Vigenère proposed the autokey: the keyword only starts the key, which then continues with the message itself, so it never repeats and Kasiski's method finds nothing. The Beaufort cipher, used on 19th-century naval cipher wheels, takes the key letter minus the plain letter instead; it is its own inverse, so the same operation encrypts and decrypts. A key of random letters as long as the message, used only once, is a one-time pad, and no amount of analysis can break it.

Finding the key length

In 1863 Friedrich Kasiski published what Charles Babbage had found a decade earlier: when the same piece of plaintext meets the same part of the key, the same ciphertext comes out, so repeated trigrams in the ciphertext tend to lie a multiple of the key length apart. Count which numbers divide their spacings and the key length stands out. William Friedman added a statistical test in the 1920s: the index of coincidence, the chance that two letters picked at random are equal, is about 0.065 for English and 0.038 for random letters. Split the ciphertext into columns for each candidate key length; at the right length every column is a simple Caesar cipher and its index jumps to that of the language.

Recovering the key

Once the length is known, each column was shifted by one key letter, so it is a Caesar cipher that frequency analysis breaks on its own. Try all 26 shifts and keep the one whose letters look most like the language, scored by chi-squared against the expected letter frequencies; the shifts of the columns spell the key. With a few dozen letters per column this almost never fails. Short texts, a key nearly as long as the text, or an autokey leave too little to work with, which is exactly what the app lets you see.

Поширені запитання

How does the Vigenère cipher work?

Each letter of the message is shifted by the letter of the key below it, with A = 0, B = 1 and so on up to Z = 25, and the key is repeated as often as needed. With the key LEMON the first letter moves 11 places, the second 4, then 12, 14 and 13, and then the pattern starts again. Decrypting shifts every letter back by the same amounts.

Who invented the Vigenère cipher?

Not Vigenère. Giovan Battista Bellaso described the repeating keyword in 1553, building on Leon Battista Alberti's cipher disc and Trithemius's tabula recta. Blaise de Vigenère described a stronger autokey cipher in 1586, and in the 19th century the simpler keyword cipher became attached to his name.

How is the Vigenère cipher cracked?

First find the key length, from the spacings between repeated sequences in the ciphertext (the Kasiski examination) or from the index of coincidence of the columns for each candidate length (Friedman's method). Then treat every column as a Caesar cipher and find its shift by frequency analysis. The shifts spell the key.

What is the index of coincidence?

The probability that two letters drawn at random from a text are the same letter. For English it is about 0.065, because some letters are far more common than others; for random letters it is 1/26, about 0.038. A Vigenère ciphertext lies in between, and its columns reach the language's value only when they are split at the true key length.

Why can't the one-time pad and the autokey be cracked here?

Both methods rely on the key repeating with a fixed period. A one-time pad's key is as long as the message and random, so there is no period at all and every plaintext of the same length is equally possible. An autokey continues with the message itself, so it never repeats either; it can be attacked by other means, by guessing probable words, but not by Kasiski's test or the index of coincidence.

Can I use the picture?

Yes. Save gives a PNG at the size you choose, Save JSON writes the cipher, the key, the result and everything the cracking found, Record films the encryption with a typewriter click per letter and a bell at the end, and the pencil opens the picture in the PictorX photo editor with the background, the tabula recta, the highlight or the chart and the message strips on layers of their own. In the editor itself it is under Apps ▸ Science ▸ Computing ▸ Vigenère Cipher. Everything runs in your browser; your messages are not sent anywhere.

Vigenère Cipher: як записати відео?

Натисніть червону кнопку «Запис» на панелі відтворення: вона знімає те, що показує сцена. Натисніть її ще раз, щоб зупинити, і відео збережеться на вашому пристрої. Запис безкоштовний, потрібно лише увійти. Без підписки на відео в куті буде невеликий логотип PictorX. Кнопка поруч із «Запис» відкриває параметри відео: формат (як показано, квадрат, сторіз 9:16 або широкий 16:9), тривалість (доки ви не зупините, або 5, 10, 15 чи 30 секунд для соцмереж) і файл: MP4, WebM або анімований GIF. Для звуку виберіть власні звуки застосунку або одну з трьох музичних доріжок: спокійну, яскраву чи ритмічну.

Готові спробувати?

Відкрийте PictorX у браузері — без встановлення і без кредитної картки.

Перейти до редактора