Understanding the Vigenère cipher tool — concept and principle
The Vigenère cipher, the classic polyalphabetic cipher, encrypts each letter with a different Caesar shift taken from a repeating key word. People use it to study cryptographic history, solve puzzles and see why repeating keys are dangerous.
How it is calculated
Number letters A = 0 … Z = 25. Write the key under the letters of the message, repeating it as often as needed, and let k_i be the key letter under the i-th letter of the message.
- Encrypt: C_i = (P_i + k_i) mod 26
- Decrypt: P_i = (C_i − k_i) mod 26
The tool removes anything that is not A–Z from the key (an empty key becomes "A", which means no shift), ignores case in the key, and advances the key position only on letters, so spaces and punctuation in the text are copied unchanged and do not use up key letters. Choose Encrypt or Decrypt in the Mode field; the single Result row shows the output, so to decode, paste the ciphertext and choose Decrypt.
The principle
Each key letter selects one of 26 Caesar alphabets. Because the same plaintext letter can turn into different ciphertext letters depending on its position, the simple letter frequencies that break a Caesar cipher are flattened out. The weakness is the repetition: letters that are a key length apart are encrypted with the same shift. Once the key length is found (Kasiski examination or the index of coincidence), the message splits into several Caesar ciphers that are each easy to solve. A key that is truly random, as long as the message and never reused is the one-time pad, which is unbreakable in principle.
Worked example
- Inputs: text "ATTACK AT DAWN", key "LEMON" (shifts 11, 4, 12, 14, 13).
- Key aligned to the letters only: ATTACK AT DAWN / LEMONL EM ONLE.
- A + L = 0 + 11 = 11 → L; T + E = 19 + 4 = 23 → X; T + M = 19 + 12 = 31 mod 26 = 5 → F; A + O = 14 → O; C + N = 15 → P; K + L = 21 → V.
- Continuing the same way gives LXFOPV EF RNHR.
- With the default mode Encrypt, the Result row shows LXFOPV EF RNHR and the Mode row says encrypted with the key. Enter LXFOPV EF RNHR and choose Decrypt to get ATTACK AT DAWN back.
How to read the result
A longer, non-repeating key makes the ciphertext harder to analyse, but any repeated key eventually leaks patterns in a long message.
Common mistakes
- Advancing the key on spaces in one tool but not in another, which shifts the alignment and garbles decryption.
- Leaving the mode on Encrypt when the text is ciphertext.
Frequently asked questions
Who invented the Vigenère cipher?
It was described by Giovan Battista Bellaso in 1553 and later misattributed to Blaise de Vigenère, who published a stronger autokey variant.
How is the cipher broken?
Find the key length with the Kasiski test or the index of coincidence, then solve each column as a Caesar cipher using letter frequencies.
Is a key as long as the message secure?
Only if it is truly random and never reused; that is the one-time pad. A long readable text as the key can still be attacked.
Sources: David Kahn, The Codebreakers, Scribner, 1996 · Simon Singh, The Code Book, Fourth Estate, 1999