How this calculator works
The key is written as a row of shifts: A means no shift, B means one step forward, and so on to Z for 25 steps. That row repeats under the message, one shift per letter, and every letter is moved forward by its own shift. Decoding moves each letter back by the same amount. Spaces, digits and punctuation keep their place and are not counted, so the key continues across them. Only the 26 Latin letters are handled; accented letters and other scripts are copied unchanged.
Formula
Write the alphabet with A = 0, B = 1, up to Z = 25. To encode, C = (P + K) mod 26, where P is the message letter and K is the key letter at that position. To decode, P = (C - K + 26) mod 26. The key repeats every time its letters run out. Only letters advance the key position.
Worked example
Encoding ATTACKATDAWN with the key LEMON repeats the key as LEMONLEMONLE. A + L is 0 + 11 = 11, which is L. T + E is 19 + 4 = 23, which is X. Following the row gives LXFOPVEFRNHR. Decoding that string with the same key returns ATTACKATDAWN.
Advertisement
Frequently asked questions
Is the Vigenère cipher secure?
No, not by modern standards. If the key is short and the message is long, the repeated key can be found by looking at repeated patterns, and a one-time pad is the only unbreakable version. Use this page to learn the method or to read historical messages, never to protect a real secret.
Why does the key stream stop at the letters?
Spaces and punctuation are not encrypted, so they do not consume a key letter. The key uses one letter for each alphabetic character only. The key stream output shows exactly which letters were applied, in order.
Does the cipher keep capital letters?
Yes. A capital letter comes back as a capital and a lowercase letter comes back as a lowercase letter, because the shift is applied within the matching case. The key itself is case-insensitive; lemon and LEMON give the same result.
What happens to accented letters or other alphabets?
They are left unchanged, because the 26-letter shift has no defined value for them. Transliterate a name to ASCII first if you want every character encrypted, and remember that the other side must use the same convention.
How do I decode a message without the key?
You have to recover the key first. With a long message, a codebreaker looks for repeated sequences to guess the key length and then solves each shift as a Caesar cipher. Short messages are much harder; the method is a puzzle, not a proof of secrecy.