🔑 Autokey Cipher

Encrypt and decrypt text with the Autokey cipher. The key extends itself with plaintext, avoiding repeated key cycles.

About the Autokey Cipher

The Autokey cipher (also called the autoclave cipher) is a polyalphabetic cipher closely related to Vigenère. Its defining feature is that the key is not simply repeated — after the initial primer key is consumed, the plaintext itself is appended to form the running key. This eliminates the short repeating cycles that make Vigenère vulnerable to Kasiski analysis. This tool runs entirely in your browser — nothing is uploaded.

How it works

  • Encrypt — Ci = (Pi + Ki) mod 26. For the first L letters, Ki comes from the primer key; afterwards Ki equals Pi−L (the plaintext L positions earlier).
  • Decrypt — Pi = (Ci − Ki) mod 26. The recovered plaintext is fed back into the key stream as decryption progresses.
  • Only A–Z letters are transformed; letter case is preserved and non-letters pass through unchanged.
  • Because the key never repeats, the periodic patterns that break Vigenère do not appear.

Use cases

  • Studying advanced polyalphabetic ciphers beyond simple Vigenère.
  • Demonstrating how a running key resists Kasiski and Friedman analysis.
  • Building educational cryptography exercises.
  • Comparing the Autokey approach with the one-time pad ideal.

Frequently asked questions

Is the Autokey cipher secure? It is stronger than Vigenère but still breakable. Because the key is derived from the plaintext, statistical attacks on the language of the plaintext can recover the primer and message.

What is the primer? The primer is the short initial key you supply. Once it is exhausted, the plaintext takes over as the key.

Why must decryption recover the plaintext step by step? Because each subsequent key letter depends on the previously recovered plaintext letter, the process must be sequential from left to right.

Does this tool upload my text? No. All encryption and decryption happens locally in your browser.