Autokey Cipher Encoder & Decoder

Vigenère variant that appends the message to the key

Free Autokey cipher tool — a Vigenère variant where the key stream is a keyword followed by the plaintext itself, so the key never repeats. Encrypt and decrypt in your browser, no upload. It runs free in your browser on Gera Tools, with nothing uploaded.

Last updated Source: Gera Tools

What makes the Autokey cipher different from Vigenère?

Both add a key letter to each plaintext letter. But Vigenère repeats a short keyword, which creates exploitable patterns. The Autokey cipher appends the plaintext to the keyword, so the key is as long as the message and never repeats.

The Autokey cipher is a polyalphabetic substitution cipher devised by Blaise de Vigenère, and it is a notable improvement on the better-known Vigenère cipher that bears his name. Its defining trick is that the encryption key extends itself with the plaintext, so the running key is exactly as long as the message and never falls into a repeating pattern.

How it works

Every letter becomes a number from 0 (A) to 25 (Z). The cipher builds a key stream: it starts with your keyword (called the primer) and then, as each plaintext letter is enciphered, appends that plaintext letter to the stream. Encryption uses the Vigenère addition rule:

C = (P + K) mod 26

where K is the current key-stream value. Because the primer is short but the plaintext continues the key, there is no short repeat for an attacker to exploit.

Decryption must run progressively. The first letters are decrypted with the keyword primer using P = (C - K) mod 26. Each recovered plaintext letter is then appended to the key stream and used to decrypt the following letter. This chaining is automatic in the tool, so you only supply the original keyword.

Only letters are enciphered and advance the key; spaces, digits and punctuation pass through untouched and keep the alignment intact.

Example

With keyword KEY and plaintext HELLO, the key stream is KEYHE — the primer KEY followed by the first two plaintext letters HE. Adding letter by letter:

P:  H  E  L  L  O
K:  K  E  Y  H  E
C:  R  I  J  S  S

Decrypting RIJSS with keyword KEY recovers H, appends it to the key, recovers E, and so on, rebuilding HELLO.

Notes

  • The Autokey cipher resists Kasiski examination because the key has no period, but error propagation means a single wrong letter garbles the rest of the message.
  • Pick a primer that is not a common word to avoid easy guessing of the opening letters.
  • For a reciprocal classical cipher where encryption equals decryption, see the Beaufort cipher.