Vigenère Cipher
Encrypt and decrypt text using the Vigenère keyword cipher with advanced options like autokey, case control, and non‑letter preservation.
Updated
What is the Vigenère Cipher?
The Vigenère cipher uses a keyword to apply different Caesar shifts to each letter in the text. Unlike a single-shift Caesar cipher, it changes the shift as it moves through the message, which makes it much harder to attack with frequency analysis.
This tool lets you encrypt or decrypt text with a keyword, switch between repeating-key and autokey modes, and keep spaces, punctuation, and casing under control. Everything runs in your browser, so you can experiment with the cipher without sending any data to a server.
Key features
- Encrypt and decrypt in either direction.
- Use a custom keyword to control the repeated shifts.
- Switch between repeating key and autokey modes.
- Preserve non-letters so spaces, punctuation, and numbers stay readable.
- Control the case of the output or keep the original casing.
- See updates instantly as you type.
- Copy or swap results for quick comparisons.
Whether you are learning classical cryptography or checking a coded message, this tool keeps the process simple and transparent.
How it works
The Vigenère cipher is built on a simple arithmetic formula that combines each plaintext letter with a corresponding letter from the keyword.
The Formula
For encryption, each letter (P) (plaintext) is shifted forward by the shift value of the key letter (K):
[ C = (P + K) \bmod 26 ]
For decryption, the process is reversed:
[ P = (C - K) \bmod 26 ]
Here, (A = 0, B = 1, \dots, Z = 25). The key letter determines the shift: for example, the key letter 'C' has a shift of 2.
Repeating Key vs. Autokey
- Repeating key: The keyword is repeated over and over to match the length of the plaintext. This is the classical Vigenère cipher.
- Autokey: The keyword is used only for the first (n) letters (where (n) is the length of the keyword). After that, the plaintext itself is used as the key. This makes the cipher more resistant to frequency analysis and avoids the repetitive weakness of the repeating key.
Non‑Letter Preservation
The cipher only acts on alphabetic characters (A–Z and a–z). When Preserve Non‑Letters is enabled, all other characters (spaces, digits, punctuation) are left untouched in the output. If disabled, non‑alphabetic characters are simply omitted from the output.
Case Handling
- Preserve case: The case of each input letter is retained in the output (e.g., 'Hello' becomes 'Rijvs' with the same case pattern).
- Force uppercase: All output letters are uppercase.
- Force lowercase: All output letters are lowercase.
The Vigenère Table (Tabula Recta)
The cipher can also be visualised using the Tabula Recta – a grid where the top row is the alphabet, and each subsequent row is shifted one letter to the left. To encrypt, find the plaintext letter in the top row, move down to the row indicated by the key letter, and read the resulting ciphertext letter.
All calculations are performed in‑memory using simple modular arithmetic, ensuring instant feedback and zero latency.
Examples
Encrypt 'HELLO' with key 'KEY'
Encrypt the plaintext 'HELLO' using the keyword 'KEY' to produce the ciphertext 'RIJVS'.
HELLORIJVSDecrypt 'RIJVS' with key 'KEY'
Decrypt the ciphertext 'RIJVS' back to the original plaintext using the same keyword.
RIJVSHELLOFrequently asked questions
What is the Vigenère cipher?
What is the Vigenère cipher?
The Vigenère cipher is a polyalphabetic substitution cipher that uses a keyword to apply multiple Caesar shifts to the letters of a plaintext. It was invented by the French cryptographer Blaise de Vigenère in the 16th century and remained unbroken for centuries.
How do I choose between repeating key and autokey?
How do I choose between repeating key and autokey?
The repeating key method is simpler and more common; it repeats your keyword over and over to match the text length. Autokey uses the plaintext itself to extend the key after the initial keyword, which makes the cipher stronger against attacks because the key stream doesn't repeat. Choose autokey if you need higher security, but be aware that decryption requires the same keyword and knowledge of the autokey method.
Is the Vigenère cipher secure today?
Is the Vigenère cipher secure today?
While it was historically considered “le chiffre indéchiffrable” (the unbreakable cipher), modern cryptanalysis has cracked it using frequency analysis and the Kasiski examination. Today, it is not considered secure for serious applications, but it remains a fascinating educational tool and a fun way to encode messages for puzzles and games.
What does “preserve non‑letters” do?
What does “preserve non‑letters” do?
When enabled, the cipher leaves spaces, punctuation, digits, and other non‑alphabetic characters exactly as they are in the input. When disabled, those characters are simply removed from the output, giving you a continuous string of letters only.
Can I decrypt a message if I don't have the key?
Can I decrypt a message if I don't have the key?
No, the Vigenère cipher requires the exact keyword to decrypt. Without it, you would have to perform a cryptanalysis attack (like Kasiski examination) to try to recover the key, which is a complex and time‑consuming process.
How does the case handling work?
How does the case handling work?
The tool gives you three options:
- Preserve case: The output keeps the original letter casing (e.g., 'Hello' → 'Rijvs').
- Force uppercase: All output letters become uppercase (e.g., 'Hello' → 'RIJVS').
- Force lowercase: All output letters become lowercase (e.g., 'Hello' → 'rijvs').
Does the tool store my text or key anywhere?
Does the tool store my text or key anywhere?
No. The entire calculation runs in your browser using JavaScript. No data is sent to any server, and nothing is stored in cookies or localStorage. Your input stays private and is never logged or recorded.
Related tools
More utilities you might find handy.
Atbash Cipher
Encode and decode text using the Atbash cipher.
Caesar Cipher
Encrypt text with a custom Caesar shift cipher or decrypt unknown messages instantly.
One-Time Pad Generator
Generate cryptographically random one-time pads and encrypt or decrypt messages with modular or XOR cipher modes entirely in your browser.