🔐 Vigenere Cipher Encoder and Decoder
By ToolNimba Text Team · Updated 2026-06-19
Enter text and a keyword to see the result.
The Vigenere cipher encrypts text by shifting each letter using a repeating keyword instead of a single fixed shift. Each keyword letter sets a shift (A = 0, B = 1, and so on), so the same plaintext letter can map to different ciphertext letters depending on its position. Type your message, pick a keyword, choose encode or decode, and this tool transforms it instantly while keeping your spaces, punctuation and letter case exactly as they were.
What is the Vigenere Cipher?
The Vigenere cipher is a polyalphabetic substitution cipher published in the 16th century and long known as le chiffre indechiffrable, the indecipherable cipher. It builds on the simple Caesar shift by using not one shift but many: a keyword is repeated across the message, and each letter of plaintext is shifted by the value of the keyword letter sitting above it. Because the shift changes from letter to letter, the same plaintext letter does not always become the same ciphertext letter, which hides the letter-frequency patterns that make a plain Caesar cipher trivial to crack.
To encode, you line the keyword up under the message, repeating it as needed, then for each plaintext letter you add the keyword letter's value (A = 0, B = 1, ... Z = 25) and wrap around the alphabet with modulo 26. Decoding reverses the step: you subtract the keyword value instead of adding it. Letters keep their case, and anything that is not a letter (spaces, digits, punctuation) is passed straight through and does not consume a keyword letter, so the keyword only steps forward on actual A to Z characters.
The cipher is a classic teaching example rather than a modern security tool. Its weakness is that the keyword repeats, so once an attacker guesses or measures the key length (using the Kasiski examination or the index of coincidence) the message splits into several Caesar ciphers that fall to frequency analysis. It is excellent for learning how keys, shifts and modular arithmetic work, for puzzles and capture-the-flag challenges, and for light obfuscation, but it should never protect anything that genuinely needs to stay secret.
When to use it
- Teaching or learning how polyalphabetic ciphers, keys and modular arithmetic work in a cryptography class.
- Solving or creating puzzle hunts, escape rooms and capture-the-flag (CTF) challenges that use a keyword cipher.
- Lightly obfuscating a note or answer key so it is not readable at a glance, without claiming real security.
- Checking your own pen-and-paper Vigenere work against a fast, exact reference before you trust the result.
How to use the Vigenere Cipher
- Type or paste your message into the text box.
- Enter a keyword (letters only, case does not matter, e.g. LEMON).
- Choose Encode to encrypt or Decode to decrypt.
- Read the transformed text in the result box and click Copy to grab it.
Formula & method
Worked examples
Encode the word HELLO with the keyword KEY.
- Repeat the keyword across the letters: K E Y K E sits under H E L L O.
- Map each keyword letter to a shift: K = 10, E = 4, Y = 24, K = 10, E = 4.
- H (7) + K (10) = 17, which is R.
- E (4) + E (4) = 8, which is I.
- L (11) + Y (24) = 35, and 35 mod 26 = 9, which is J.
- L (11) + K (10) = 21, which is V. O (14) + E (4) = 18, which is S.
Result: HELLO with keyword KEY encodes to RIJVS.
Encode the classic phrase ATTACKATDAWN with the keyword LEMON.
- Repeat the keyword: LEMONLEMONLE lines up under ATTACKATDAWN.
- A (0) + L (11) = 11 gives L, T (19) + E (4) = 23 gives X, T (19) + M (12) = 31 mod 26 = 5 gives F.
- A (0) + O (14) = 14 gives O, C (2) + N (13) = 15 gives P, K (10) + L (11) = 21 gives V.
- A (0) + E (4) = 4 gives E, T (19) + M (12) = 31 mod 26 = 5 gives F, D (3) + O (14) = 17 gives R.
- A (0) + N (13) = 13 gives N, W (22) + L (11) = 33 mod 26 = 7 gives H, N (13) + E (4) = 17 gives R.
- To decode, switch the mode and subtract each keyword shift instead of adding it.
Result: ATTACKATDAWN with keyword LEMON encodes to LXFOPVEFRNHR.
Keyword letters and the shift each one applies (A = 0)
| Keyword letter | Shift value | Effect on plaintext A | Effect on plaintext M |
|---|---|---|---|
| A | 0 | A (no change) | M (no change) |
| E | 4 | E | Q |
| K | 10 | K | W |
| N | 13 | N | Z |
| Y | 24 | Y | K (wraps around) |
Vigenere compared with the simpler Caesar shift
| Feature | Caesar cipher | Vigenere cipher |
|---|---|---|
| Key | One number (single shift) | A keyword (many shifts) |
| Type | Monoalphabetic | Polyalphabetic |
| Same letter maps to | Always the same letter | Different letters by position |
| Frequency analysis | Breaks it easily | Needs key length first |
Common mistakes to avoid
- Counting non-letters when stepping the keyword. Spaces, digits and punctuation should pass through unchanged and must not advance the keyword. If you shift the keyword on a space, every letter after it lines up with the wrong key letter and decoding fails. This tool only steps the keyword on A to Z characters.
- Using a keyword with spaces or numbers. Only the letters A to Z carry a shift. Strip out spaces, digits and symbols from your keyword first, or the encoder and the decoder may disagree about which characters count.
- Mismatching encode and decode keywords. You must decode with exactly the same keyword you encoded with. A single different or missing letter throws off the alignment from that point onward and produces garbage.
- Treating it as real encryption. The repeating keyword makes Vigenere breakable with the Kasiski test and frequency analysis. It is fine for puzzles and learning, but never use it to protect passwords, private messages or anything sensitive.
Glossary
- Plaintext
- The original readable message before it is encrypted.
- Ciphertext
- The scrambled output after the cipher has been applied.
- Keyword
- The repeating word whose letters set the shift for each letter of the message.
- Polyalphabetic cipher
- A cipher that uses several different substitution alphabets, switching between them as it encrypts.
- Shift
- How many places along the alphabet a letter moves, given by a keyword letter (A = 0 up to Z = 25).
- Modulo 26
- Wrapping arithmetic around the 26-letter alphabet so that going past Z returns to A.
Frequently asked questions
What is the Vigenere cipher?
It is a polyalphabetic substitution cipher that encrypts text by shifting each letter using a repeating keyword. Each keyword letter sets a shift (A = 0, B = 1, and so on), so the same plaintext letter can become different ciphertext letters depending on its position, which hides the letter patterns a simple shift would expose.
How do I decode a Vigenere message?
Select Decode mode and enter the exact keyword that was used to encrypt it. The tool subtracts each keyword shift instead of adding it, reversing the encryption. Without the correct keyword you cannot recover the original message directly.
Does the keyword skip spaces and punctuation?
Yes. Spaces, digits and punctuation pass through unchanged and do not advance the keyword. The keyword only steps forward on actual letters (A to Z), so encoding and decoding stay aligned no matter how the text is spaced.
Is the Vigenere cipher secure?
No. Because the keyword repeats, an attacker can estimate its length with the Kasiski examination or the index of coincidence, then break each slice with frequency analysis. It is great for learning and puzzles but should never protect anything that truly needs to stay private.
How is it different from a Caesar cipher?
A Caesar cipher uses one fixed shift for every letter, so it is monoalphabetic. Vigenere uses a keyword that supplies many different shifts, making it polyalphabetic. That is why the same plaintext letter maps to different ciphertext letters and why Vigenere is harder to crack.
Is my text sent anywhere?
No. The cipher runs entirely in your browser with plain JavaScript. Your text and keyword never leave your device, there are no network requests, and nothing is stored after you close the page.