Autokey Cipher
Free online autokey cipher: a Vigenère-style cipher whose key is your keyword followed by the message itself. Encrypt, decrypt, and follow a worked example.
How to Use Autokey Cipher
- Enter plaintext and a letters-only keyword.
- Choose Encrypt; the default keyword is QUEENLY and spaces do not consume key characters.
- For decryption, switch modes and supply the same keyword used to encrypt.
- Keep Preserve Spaces on for matching punctuation and spacing, then copy the result.
The component starts with the keyword, then extends the keystream with plaintext letters. Each alphabetic character is shifted by its corresponding keystream letter.
Examples
Keyword QUEENLY — plaintext:
ATTACK AT DAWN
Output:
QNXEPV YT WTWP
Keyword KEY — plaintext:
HELLO
Output:
RIJSS
How the autokey is built
The key is your keyword followed by the message itself. With keyword KEY and the message ATTACK AT DAWN, the key starts K-E-Y and then continues with the plaintext letters: KEYATTACKATD. Only letters count, so spaces do not use up key characters. Each letter is then shifted exactly as in the Vigenère cipher, with A = 0 through Z = 25 and the sum taken mod 26.
The difference from Vigenère is only the key: a repeating keyword there, keyword-then-plaintext here. That one change means the key never repeats, however long the message is.
Worked example: ATTACK AT DAWN with keyword KEY
Every value below is what this tool computes. Position, plaintext letter, key letter (from the keyword for the first three, then from the plaintext), the sum, and the resulting ciphertext letter:
| # | Plain | Key | Plain + Key (mod 26) | Cipher |
|---|---|---|---|---|
| 1 | A | K | 0 + 10 = 10 | K |
| 2 | T | E | 19 + 4 = 23 | X |
| 3 | T | Y | 19 + 24 = 43 → 17 | R |
| 4 | A | A | 0 + 0 = 0 | A |
| 5 | C | T | 2 + 19 = 21 | V |
| 6 | K | T | 10 + 19 = 29 → 3 | D |
| 7 | A | A | 0 + 0 = 0 | A |
| 8 | T | C | 19 + 2 = 21 | V |
| 9 | D | K | 3 + 10 = 13 | N |
| 10 | A | A | 0 + 0 = 0 | A |
| 11 | W | T | 22 + 19 = 41 → 15 | P |
| 12 | N | D | 13 + 3 = 16 | Q |
ATTACK AT DAWN becomes KXRAVD AV NAPQ. Notice the key letters from position 4 onward are just the plaintext moved three places to the right (A-T-T-A-C-K-A-T-D).
Decoding it back, step by step
- Subtract the keyword from the first three ciphertext letters: K−K = A, X−E = T, R−Y = T. That gives ATT.
- Those three letters are now the key for the next three: A, V, D minus A, T, T gives A, C, K. So far ATTACK.
- ACK is the key for the next three: A, V, N minus A, C, K gives A, T, D. The plaintext is now ATTACKATD.
- ATD is the key for the last three: A, P, Q minus A, T, D gives A, W, N. The full message is ATTACK AT DAWN.
Each block of decrypted text becomes the key for the next block, so you must have the exact keyword to begin the chain. Try it in the tool above: paste KXRAVD AV NAPQ, switch to Decrypt, and enter KEY.
Autokey vs Vigenère on the same message
Same message (ATTACK AT DAWN) and same 7-letter keyword (QUEENLY), two different keys:
| Cipher | Key used | Ciphertext |
|---|---|---|
| Vigenère | QUEENLY QUEEN | QNXEPVY JXEAA |
| Autokey | QUEENLY ATTAC | QNXEPVY TWTWP |
The first seven letters match because both ciphers use the keyword there. From letter eight on, the keys differ and so do the results. The practical effect: Vigenère’s repeating key leaves periodic fingerprints that attacks on Vigenère exploit, while autokey’s non-repeating key removes that specific fingerprint. Other keyed relatives worth comparing are the running key and Gronsfeld ciphers.
What one mistake does to the message
Because decrypted letters feed the key, errors travel. We encrypted THE QUICK BROWN FOX JUMPS with keyword LEMON (5 letters) and tried two kinds of mistake:
- One ciphertext letter altered. Decrypting gave
THE QNICK BYOWN FHX JUMWS. The damaged letters (U→N, R→Y, O→H, P→W) sit exactly 5 letters apart, the keyword length — all the other letters decrypt correctly. - Keyword off by one letter (LEMOX instead of LEMON). Decrypting gave
THE QKICK BBOWN FEX JUMZS. Only every 5th letter is wrong, so the message is still readable.
That is a useful rule of thumb when decoding: text that is almost readable with a repeating gap pattern usually means a near-miss keyword, not the wrong cipher.
How strong is it, and where did it come from?
It is a puzzle and teaching cipher, not protection. A 3-letter keyword has only 17,576 possibilities and a 5-letter one 11,881,376 — trivial for a computer. Guessed plaintext also gives the key away: subtract a guessed start ATT from the ciphertext K, X, R and you get K, E, Y — the keyword. For solving techniques on related ciphers see frequency analysis and the frequency analysis tool.
Historically, the idea belongs to 16th-century cryptographers; Blaise de Vigenère described a version in his 1586 Traicté des chiffres, and the repeating-key cipher that now carries his name is in fact the simpler one. This tool implements the plaintext-autokey form shown above (not the ciphertext-autokey variant).
Frequently Asked Questions
What is the autokey cipher?
The autokey cipher is a Vigenère-style substitution cipher whose key is not repeated. It starts with a short keyword and then continues the key with the plaintext itself, so the key is as long as the message. Each letter is shifted by the matching key letter, exactly as in Vigenère, with A=0 through Z=25.
How is autokey different from the Vigenère cipher?
Vigenère repeats the keyword (QUEENLYQUEENLY…), while autokey uses the keyword once and then the plaintext (QUEENLYATTACKAT…). The first keyword-length letters of the ciphertext are identical in both; after that they diverge. Because the key never repeats, the repeating-key pattern that Kasiski examination relies on is gone.
How do you decrypt an autokey cipher?
Subtract the keyword from the first ciphertext letters to recover the first plaintext letters. Those recovered letters are the next part of the key, so use them to decrypt the following letters, and keep going. Each decrypted block becomes the key for the block after it. You need the exact keyword to start the chain.
What happens if one letter is wrong?
A single wrong letter damages that position and then every keyword-length position after it, because each wrong plaintext letter becomes a wrong key letter one keyword-length later. With the keyword LEMON (5 letters), one altered ciphertext letter garbled every 5th letter after it. A one-letter typo in the keyword garbles only every 5th letter starting from that keyword position, so the rest of the text stays readable.
Is the autokey cipher secure?
No. It is stronger than a short repeating Vigenère key, but it is a classical cipher and should not protect real secrets. A short keyword can be brute-forced (a 5-letter keyword has only 11,881,376 possibilities), and a known or guessed piece of plaintext reveals the key letters at that position. Use it for puzzles, teaching and history, not for security.
Features
Privacy Focused
All processing happens in your browser. No data is sent to servers.
Free Forever
No registration, no limits, completely free to use.