Autokey Cipher

The Autokey Cipher is a polyalphabetic substitution cipher that uses a priming key followed by the plaintext itself (or ciphertext) to generate the keystream. This addresses the periodicity weakness of the Vigenère cipher by making the key as long as the message.

10Worksheets
200+Practice Questions
HardDifficulty
2-3 hoursHours to Master

Introduction to Autokey Cipher

The Autokey Cipher is a polyalphabetic substitution cipher that uses a priming key followed by the plaintext itself (or ciphertext) to generate the keystream. This addresses the periodicity weakness of the Vigenère cipher by making the key as long as the message.

Prerequisites

Vigenère cipher Key extension concepts Plaintext feedback Modular arithmetic
Why This Matters: Autokey Cipher problems appear in 0-1 questions in advanced exams. They test understanding of key extension techniques.

How to Solve Autokey Cipher Problems

1

Step 1: Start with the priming key (keyword) as the initial keystream

2

Step 2: For encoding, extend keystream with the plaintext itself

3

Step 3: Apply Vigenère addition: C = (P + K) mod 26

4

Step 4: For decoding, start with priming key, then use decoded plaintext to extend keystream

5

Step 5: P = (C - K) mod 26, then add P to keystream for next positions

Pro Strategy: For autokey with plaintext feedback, the keystream is priming key + plaintext (excluding the priming key length). For decoding, use priming key + decoded plaintext. Keep track of the keystream as you go.

Example Problem

Example: Encode 'HELLO' with priming key 'KEY' using autokey (plaintext feedback). Solution: Step 1: Priming key: K(10), E(4), Y(24) Step 2: Keystream: K E Y + plaintext: H E L L O (8,4,11,11,14) Step 3: Full keystream: 10,4,24,8,4,11,11,14 (for 8 letters? Actually message length 5, so keystream length 5? Wait, priming key length 3, so we need 2 more from plaintext: H(7) and E(4) -> total keystream: 10,4,24,7,4) Step 4: C = (P+K) mod 26: H(7)+10=17→R E(4)+4=8→I L(11)+24=35→35-26=9→J L(11)+7=18→S O(14)+4=18→S Step 5: Ciphertext: RIJSS Answer: RIJSS

Pro Tips & Tricks

  • Two variants: plaintext autokey (uses plaintext for keystream) and ciphertext autokey
  • Plaintext autokey is more common in competitive exams
  • The keystream length equals the message length
  • Priming key is the only shared secret between encoder and decoder
  • Decoding requires knowing the priming key only; the rest is derived
  • Autokey eliminates the periodic pattern of Vigenère

Shortcut Methods to Solve Faster

Encoding keystream = priming_key + plaintext (excluding priming_key length)
Decoding keystream = priming_key + decoded_plaintext
Use Vigenère addition and subtraction formulas

Common Mistakes to Avoid

Using the wrong feedback (plaintext vs ciphertext)
Not extending the keystream to the full message length
Confusing the order of keystream generation
Applying Vigenère incorrectly

Exam Importance

Autokey Cipher is an important topic for various competitive exams. Here's how frequently it appears:

SSC CGL
0-1 questions
BANKING PO
0-1 questions
RAILWAYS RRB
0-1 questions
CAT
1-2 questions
INSURANCE
0-1 questions

Ready to Master Autokey Cipher?

Start with Worksheet 1 and work your way up to expert level! Each worksheet includes:

20 practice questions
Detailed solutions
Step-by-step explanations
Start Practicing Now