Autokey Cipher

Polyalphabetic cipher using plaintext as key extension

Key Settings

Initial key that will be extended with plaintext

Text Processing

How it works: The key is extended with the plaintext itself, making it more secure than standard Vigenère cipher.
Error message
Copied!

Autokey Process Visualization

Plaintext:
-
Extended Key:
-
Ciphertext:
-

Key Extension Example:

If plaintext is "HELLO WORLD" and primer is "SECRET":

  • Primer: SECRET
  • Extended Key: SECRETHELLOWORLD (primer + plaintext)
  • Result: Each letter encrypted with corresponding key letter

What is the Autokey Cipher?

The Autokey cipher is a polyalphabetic substitution cipher invented by Blaise de Vigenère in the 16th century. Unlike the standard Vigenère cipher which repeats a short key, the Autokey cipher extends the key by appending the plaintext itself, making it more resistant to frequency analysis and Kasiski examination attacks.

How the Autokey Cipher Works

Encryption Process

  1. Start with a Primer: Begin with a short initial key (the primer), for example "SECRET"
  2. Extend the Key: Append the plaintext to the primer to create the extended key
  3. Encrypt Letter by Letter: Use each letter of the extended key to encrypt the corresponding plaintext letter using Vigenère-style substitution
  4. Formula: Ci = (Pi + Ki) mod 26

Example Encryption

Plaintext: HELLO WORLD
Primer:    SECRET
Extended:  SECRETHELLOW  (primer + plaintext without spaces)

H + S = Z    (7 + 18 = 25 = Z)
E + E = I    (4 + 4 = 8 = I)
L + C = N    (11 + 2 = 13 = N)
L + R = C    (11 + 17 = 2 = C)
O + E = S    (14 + 4 = 18 = S)

Result: ZINCS RFIWJ

Decryption Process

  1. Start with Primer: Use the same initial key
  2. Decrypt First Letter: Use the primer to decrypt the first ciphertext letters
  3. Build Extended Key: As you decrypt, append each decrypted letter to the key
  4. Continue: Use the growing key to decrypt subsequent letters
  5. Formula: Pi = (Ci - Ki) mod 26

Key Features

  • Self-Synchronizing: The key automatically extends with the plaintext
  • No Key Repetition: Unlike Vigenère, the key doesn't repeat in a pattern
  • Variable Key Length: The effective key length equals the message length
  • Improved Security: More resistant to frequency analysis than Vigenère
  • Simple Implementation: Easy to implement with just a short primer

Autokey vs Vigenère Cipher

Aspect Autokey Cipher Vigenère Cipher
Key Type Primer + plaintext Repeated keyword
Key Length Equals message length Fixed, repeats
Key Repetition No repetition Regular repetition
Security More secure Less secure
Vulnerability Known plaintext attacks Kasiski examination
Complexity Slightly more complex Simpler

Historical Context

The Autokey cipher was invented by Blaise de Vigenère in 1586, actually before the cipher commonly known as the "Vigenère cipher" which was misattributed to him. The Autokey cipher was Vigenère's original contribution to cryptography, representing a significant improvement over earlier polyalphabetic ciphers.

Despite its improved security, the Autokey cipher never gained the popularity of the standard Vigenère cipher, likely due to its slightly more complex encryption and decryption processes. It remained in limited use until the 20th century when modern cryptanalysis made both ciphers obsolete for serious cryptographic applications.

Security Analysis

Strengths

  • No Periodic Key: Eliminates vulnerability to Kasiski examination
  • Variable Substitution: Each letter encrypted differently based on position
  • Longer Effective Key: Key length matches plaintext length
  • Frequency Masking: Better at hiding letter frequency patterns

Weaknesses

  • Known Plaintext Attack: If part of plaintext is known, the key can be derived
  • Probable Word Attack: Common words can be tested to find the primer
  • Error Propagation: One decryption error cascades to all following characters
  • Statistical Analysis: Still vulnerable to advanced statistical methods
  • Modern Cryptanalysis: Easily broken with computer analysis

Cryptanalysis Methods

1. Known Plaintext Attack

If an attacker knows any portion of the plaintext and corresponding ciphertext, they can recover that portion of the extended key, which reveals the plaintext at that position:

Known: Plaintext = "HELLO", Ciphertext = "ZINCS"
Key recovery: K = C - P (mod 26)
Z - H = S, I - E = E, N - L = C, C - L = R, S - O = E
Recovered key: SECRET (this is the primer!)

2. Probable Word Method

Try common words or phrases at different positions in the ciphertext to see if they yield meaningful plaintext when decrypted.

3. Crib Dragging

Test known or suspected plaintext fragments (cribs) at various positions to find matches.

Practical Applications

Historical Use

  • 16th-17th Century: Used by European diplomats and military
  • Personal Correspondence: Employed for private letters among educated elite
  • Limited Military Use: Some military applications during Renaissance

Modern Usage

  • Educational Tool: Teaching cryptography concepts and polyalphabetic ciphers
  • Puzzle Creation: Used in cryptographic puzzles and games
  • Historical Reenactment: Period-appropriate encryption for historical societies
  • Hobby Cryptography: Amateur cryptographers and cipher enthusiasts

Implementation Variations

Standard Autokey

Uses plaintext to extend the key after the primer.

Autokey with Ciphertext

Some variants use the ciphertext instead of plaintext to extend the key, making decryption slightly different.

Multiple Primer Autokey

Uses multiple primers at different intervals for added complexity.

Breaking the Cipher

Despite being more secure than Vigenère, the Autokey cipher can be broken with modern techniques:

  1. Dictionary Attack: Try common words as primers
  2. Pattern Recognition: Look for repeated patterns that might indicate common plaintext
  3. Language Statistics: Use statistical properties of the language
  4. Computational Brute Force: Modern computers can try all possible primers quickly

Security Warning

  • Not for Serious Use: Do not use for protecting sensitive information
  • Educational Only: Suitable for learning and recreational purposes
  • Easily Broken: Can be cracked with modern computational methods
  • Use Modern Encryption: Use AES, RSA, or other modern algorithms for real security

Tips for Using Autokey Cipher

  1. Choose Strong Primer: Use a random, non-obvious primer for better security
  2. Longer Primer: Longer primers provide more initial security
  3. Avoid Common Words: Don't use dictionary words as primers
  4. Secure Key Exchange: Share the primer securely with the recipient
  5. Double Check: Verify decryption with test messages
  6. Clean Plaintext: Remove formatting for consistent encryption

Key Takeaways

  • Autokey cipher extends the key with plaintext itself
  • More secure than standard Vigenère cipher due to non-repeating key
  • Invented by Blaise de Vigenère in 1586
  • Vulnerable to known plaintext attacks and modern cryptanalysis
  • Useful for educational purposes and historical study
  • Not suitable for protecting sensitive information today