Autokey Cipher
Encode and decode the autokey cipher, the stronger Vigenère variant where a short primer keyword starts the key and your message itself continues it, so the key never repeats. Switch between encode and decode and watch the working build live. Everything runs in your browser.
Keyword
Enter a short primer keyword such as QUEENLY. It starts the key stream, which then continues with your message itself so the key never repeats. Only letters are used; uppercase and lowercase are treated the same, and any spaces, digits, or punctuation in the keyword are ignored.
Enter text above to see the autokey result here.
How to use Autokey Cipher
- 1
Choose encode or decode
Pick Encode to turn plaintext into autokey ciphertext, or Decode to recover the plaintext from ciphertext. The same primer keyword is used for both directions.
- 2
Enter the primer keyword
Type a short keyword such as QUEENLY. It starts the key stream, which then continues with your message itself. Only letters are used, and case, spaces, and punctuation in the keyword are ignored.
- 3
Type or paste your text
Enter the message you want to convert. The cipher runs automatically as you type, and the letter-by-letter working updates live below, showing which key letters come from the keyword and which come from the message.
- 4
Read, copy, and share
Read the result, then copy it, download it as a text file, or share a link that reopens the tool with your exact keyword, direction, and text. Everything stays in your browser.
Understanding the Autokey Cipher
What is the autokey cipher?
The autokey cipher, also called the autoclave cipher, is a polyalphabetic substitution cipher in which the message itself becomes part of the key. A short primer keyword starts the key stream, and once those letters run out the key simply continues with the letters of the plaintext. Because the running key is as long as the message and never repeats, the autokey cipher avoids the regular, cyclic pattern that makes an ordinary repeating-key cipher easy to break.
It was published by the French diplomat Blaise de Vigenère in 1586, drawing on an earlier idea by Giovan Battista Bellaso. There is a well-known irony here: the simple repeating-key cipher that the world now calls the Vigenère cipher was actually Bellaso's, while Vigenère's own, stronger invention was this autokey. By feeding the plaintext back into the key, the autokey cipher removes the periodicity that later cryptanalysts such as Kasiski and Friedman would exploit to crack repeating keys.
How the autokey cipher works
Number the alphabet from A as 0 to Z as 25. Build the key stream by writing the primer keyword first, then continuing with the plaintext letters in order. Line that stream up under the message so one key letter sits beneath every plaintext letter. To encrypt, add each key letter to the letter above it and wrap around the alphabet with a remainder by 26, so the ciphertext letter is C = (P + K) mod 26.
Decryption has to work from left to right. You know the primer keyword, so you can recover the first few letters with P = (C − K) mod 26. Each plaintext letter you recover is then appended to the key stream and used to decrypt the next letter, and so on to the end. As with the Vigenère cipher, only the 26 letters are transformed: spaces, punctuation, and digits pass through untouched and do not consume a key letter, and letter case is preserved.
Worked example
Encrypt the message HELLO with the primer keyword KEY. The key stream is the keyword followed by the plaintext, which gives K, E, Y, H, E for the five letters. Adding each to the message gives H plus K is R, E plus E is I, L plus Y is J, L plus H is S, and O plus E is S. The ciphertext is RIJSS, and notice that the last two key letters, H and E, are simply the first two letters of the message itself.
To decrypt RIJSS you start with the keyword KEY. R minus K is H, I minus E is E, and J minus Y is L, which recovers HEL. Those recovered letters now extend the key, so the next key letter is H and S minus H is L, then the key letter E gives S minus E is O, completing HELLO. Each recovered letter unlocks the next, which is the heart of how an autokey cipher is read.
Autokey versus the repeating-key Vigenère
The ordinary Vigenère cipher repeats its keyword over and over: with the key KEY the stream is KEYKEYKEY and so on. That repetition is its fatal flaw, because the key length can be found by the Kasiski examination or the index of coincidence, after which each column is a simple Caesar shift. The autokey cipher uses the same addition rule but never repeats the key, so those classic tests do not apply.
You can see the difference in the worked example. With the key KEY, a repeating Vigenère would encrypt HELLO as RIJVS, while the autokey produces RIJSS — the two agree only while the keyword lasts and then diverge, because the autokey has moved on to the plaintext. That single change, feeding the message back into the key, was Vigenère's real contribution and made his cipher markedly stronger than the one that now bears his name.
Autokey versus the running-key cipher
The autokey cipher is closely related to the running-key cipher. Both use a key as long as the message so that nothing repeats, but they differ in where that long key comes from. A running-key cipher draws its key from a shared external text, such as an agreed page of a book, while the autokey cipher generates its long key from a short primer plus the plaintext itself.
Each approach has a catch. A running key taken from natural language carries its own statistical structure that can be attacked, but it needs no plaintext feedback. The autokey needs only a tiny shared secret, the primer keyword, but because part of its key is the plaintext, an attacker who guesses a common word can try sliding it through the message as if it were key, which is the main way autokey ciphers are broken.
How to break the autokey cipher
Because the key never repeats, the Kasiski examination and the index of coincidence, the standard tools against repeating-key ciphers, do not work directly on an autokey message. That makes it noticeably tougher than Vigenère, but it is still far from secure. The usual attack exploits the very feature that defines the cipher: most of the key is the plaintext, which is ordinary language.
An analyst guesses a probable word, such as THE or a likely name, and drags it across the ciphertext, subtracting it as if it were key. Where the guess is correct the operation reveals fragments of more plaintext, which can then be extended in both directions. Combined with brute-forcing the short primer keyword, this crib-dragging recovers autokey messages by hand, so the cipher is best seen as a clever historical step forward rather than a safe choice.
Is the autokey cipher secure?
No. Although the autokey cipher is stronger than a plain repeating-key Vigenère, it offers no real protection by modern standards. Its reliance on the plaintext as key opens it to crib-dragging, and its short primer can be brute-forced, so a determined analyst can break it with pencil and paper. It belongs to the history of classical cryptography rather than to any list of secure methods.
Today the autokey cipher is valued for learning and for play. It is an elegant way to see how feeding the message back into the key defeats the periodicity attacks that crack simpler ciphers, and it appears in puzzle hunts, escape rooms, and capture-the-flag challenges. For protecting real information you should rely on modern, well-tested algorithms such as AES instead.
Frequently asked questions
What is the autokey cipher?
How does the autokey cipher work?
How is the autokey cipher different from the Vigenère cipher?
Can you show an autokey cipher example?
What keyword should I use?
How do I decode an autokey cipher?
What is the difference between autokey and running-key ciphers?
Does the cipher change spaces, digits, and punctuation?
Is the keyword case sensitive?
How do you break the autokey cipher?
Is the autokey cipher secure?
Is my text uploaded to a server?
Related tools
Keep going with these handy tools