About the Vigenere Cipher
The Vigenère cipher shifts each letter by a different amount set by a keyword, and for about three centuries it was considered unbreakable. This tool encrypts and decrypts with any keyword, keeping capitals, spaces and punctuation, and shows which key letter applies to each character: the classic example ATTACKATDAWN with the key LEMON becomes LXFOPVEFRNHR. It is ideal for teaching, puzzles and escape rooms, though modern computers break it easily. Only the letters of the keyword count, so spaces, digits and punctuation in the key are ignored, and capital and small letters work the same way.
Each letter of the keyword stands for a shift: A is 0, B is 1 and so on to Z, 25. The keyword is repeated along the message, and each letter of the message is shifted forward by the matching key letter; decrypting shifts back. In this standard form the key only advances on letters, so spaces and punctuation do not use up key letters. Because the same letter is encrypted differently depending on its position, letter frequencies are hidden, although the repeating key can be found with methods such as the Kasiski examination.
Example: the classic textbook message ATTACKATDAWN encrypted with the key LEMON becomes LXFOPVEFRNHR, and attack at dawn becomes lxfopv ef rnhr with the spaces kept. Decrypting LXFOPVEFRNHR with LEMON gives ATTACKATDAWN again.
A long, random key that is never reused would make this a one-time pad, but a short keyword can be broken. For modern protection use text encryption with AES. The Caesar cipher is the single-shift version, and ROT13 and the Atbash cipher are other classics.
How to use the Vigenere Cipher
- Choose encrypt or decryptSwap direction at any time.
- Enter the keywordLetters only; other characters are ignored.
- Type or paste the messageCase, spaces and punctuation are kept.
- Read the resultWith the key letter used for each letter shown below.
Vigenere Cipher features
- Encrypt and decrypt
- Any keyword
- Keeps case, spaces and punctuation
- Key advances only on letters
- Key letters shown under the message
- Swap direction in one click
- Instant results
Common uses
- Cipher puzzles and escape rooms
- Cryptography lessons
- Treasure hunts and geocaching
- Checking hand-made ciphers
- History of codes projects
The Vigenère cipher in practice: encrypting with a keyword, finding the key length, wartime failures, the autokey variant and puzzle design
The Vigenère cipher shifts each letter by a different amount according to a keyword, which defeats simple letter counting and kept it unbroken for centuries. Learning how it works, and how it was finally broken, is one of the best introductions to cryptanalysis. This guide encrypts a message, explains how codebreakers find the key length, recounts a wartime failure, describes the stronger autokey variant and offers tips for puzzle makers.
A worked example: a keyword cipher
Encrypting SEND BOOKS TO SCHOOL with the keyword LAHORE produces DEUR SSZKZ HF WNHVCC. The keyword repeats along the letters, so S is shifted by L, 11 places, E by A, which leaves it unchanged, N by H and so on. The same letter in the message can become different letters in the ciphertext, which is what made the cipher so much stronger than a single shift.
Finding the key length
The cipher's weakness is the repeating keyword. If the same word in the message lines up with the same part of the key twice, it produces identical ciphertext, and the distance between repeats is a multiple of the key length. Friedrich Kasiski published this method in 1863, although Charles Babbage had found similar ideas earlier without publishing them. Statistical measures, such as the index of coincidence, confirm the likely length.
Breaking each column
Once the key length is known, the ciphertext splits into columns, one for each letter of the key. Every column is simply a Caesar cipher, which frequency analysis breaks quickly. Reassembling the shifts reveals the keyword. Seeing the method work on a long message is a memorable lesson in why repetition is dangerous in cryptography.
A wartime failure
During the American Civil War, the Confederacy used Vigenère ciphers with brass cipher discs and keywords such as Manchester Bluff and Complete Victory. Union codebreakers regularly read the messages, helped by the short, reused keys and by messages that left some words unencrypted. It is a striking real example of a sound idea undone by poor key choices.
The autokey variant
Blaise de Vigenère himself described a stronger version, the autokey cipher, in which a short primer starts the key and the message itself continues it. Because the key no longer repeats, the Kasiski method fails. It can still be broken with more effort, but it shows how a small change in design removes a major weakness.
Long random keys
If the key is truly random, as long as the message and never reused, the cipher becomes a one-time pad, which is unbreakable in principle. The practical problem is sharing and protecting such long keys, which is why modern systems use algorithms such as AES with short keys instead.
Designing puzzles
For a puzzle, choose a keyword players can deduce from a clue, such as a place, a person or a date written as letters. Keep messages short enough to solve by hand, and test the puzzle on someone else before using it. A printed Vigenère square, the 26 by 26 table of shifted alphabets, makes manual solving far easier.
Doing it by hand
To encrypt on paper, write the keyword repeatedly above the message, then find each message letter's column in the Vigenère square and read the row of the key letter. Doing a short message by hand once makes the mechanism clear, and the tool can then check the result.
Common mistakes
- Choosing a short keyword for a long message.
- Reusing the same keyword for many messages.
- Advancing the key on spaces when the recipient does not.
- Treating the cipher as secure for real secrets.
Related tools
For the single-shift version, use Caesar Cipher. For modern protection, try Encrypt Text Online, and to pick unpredictable keywords for puzzles, Random Word Generator.
Choosing keys for practice
Longer keywords make the cipher harder to break, and keywords with varied letters work better than ones with repeats. A keyword made only of the letter A shifts nothing at all, and one with many repeated letters behaves like a shorter key. For practice, compare how quickly short and long keys can be broken.
The Beaufort variant
The Beaufort cipher, a close relative, subtracts each message letter from the key letter instead of adding them. A neat property follows: the same operation both encrypts and decrypts. It was used historically on cipher machines and is a good extension exercise once the standard cipher is familiar.
A programming assignment
Implementing the cipher is a common programming assignment. The main pitfalls are advancing the key on spaces and punctuation, mishandling lower-case letters and forgetting to wrap around the alphabet. Testing with the ATTACKATDAWN and LEMON example, which must produce LXFOPVEFRNHR, quickly shows whether the implementation is correct.
Checking a decryption
When decrypting by hand, a wrong key letter produces one garbled letter in every cycle of the key, at the same position each time. Spotting that regular pattern of errors tells you which key letter is wrong, so you can fix it without starting again from the beginning.
Privacy
Encryption and decryption run in your browser. Your text and keyword are not uploaded or stored.
Frequently asked questions
How does the Vigenère cipher work?
Write the keyword repeatedly under the message. Each key letter gives a shift (A = 0 to Z = 25) for the message letter above it. Shift forward to encrypt and backward to decrypt.
How do I decrypt a Vigenère cipher?
Enter the same keyword and choose decrypt. Each letter is shifted back by its key letter. Without the keyword, cryptanalysis methods such as the Kasiski test or frequency analysis are needed.
What is the classic example?
ATTACKATDAWN with the key LEMON gives LXFOPVEFRNHR. It appears in many textbooks and is a good check that a tool works the standard way. Decrypting LXFOPVEFRNHR with the same key gives the original message back.
Is the Vigenère cipher secure?
Not by modern standards. Charles Babbage and Friedrich Kasiski showed in the 1800s how to find the key length and break it. A random key as long as the message would be unbreakable, but that is a one-time pad.
Do spaces and punctuation use key letters?
Not in this standard version: the key only advances on letters. Some puzzles advance the key on every character, so if a solution looks wrong, that may be why.
Who invented the Vigenère cipher?
It was first described by Giovan Battista Bellaso in 1553 and later misattributed to Blaise de Vigenère, who published a stronger autokey cipher in 1586.
What is the Vigenère square?
The tabula recta: a 26 × 26 table of shifted alphabets. Find the message letter's column and the key letter's row; their crossing is the encrypted letter.
Can the keyword contain spaces or numbers?
Only letters count. Spaces, digits and punctuation in the keyword are ignored, and upper and lower case are treated the same, so Lemon 1 works exactly like LEMON. Longer keywords without repeating patterns are harder to break.