Autokey Cipher

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 4

Autokey Cipher

Introduction
The Autokey Cipher is a polyalphabetic substitution cipher. It is closely related to the
Vigenere cipher, but uses a different method of generating the key. It was invented by Blaise
de Vigenre in 1586, and is in general more secure than the Vigenere cipher.

The Algorithm
The 'key' for the Autokey cipher is a key word. e.g. 'FORTIFICATION'
The Autokey cipher uses the following tableau (the 'tabula recta') to encipher the plaintext:
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
--------------------------------------------------A

A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

B C D E F G H I J K L M N O P Q R S T U V W X Y Z A

C D E F G H I J K L M N O P Q R S T U V W X Y Z A B

D E F G H I J K L M N O P Q R S T U V W X Y Z A B C

E F G H I J K L M N O P Q R S T U V W X Y Z A B C D

F G H I J K L M N O P Q R S T U V W X Y Z A B C D E

G H I J K L M N O P Q R S T U V W X Y Z A B C D E F

H I J K L M N O P Q R S T U V W X Y Z A B C D E F G

I J K L M N O P Q R S T U V W X Y Z A B C D E F G H

J K L M N O P Q R S T U V W X Y Z A B C D E F G H I

K L M N O P Q R S T U V W X Y Z A B C D E F G H I J

L M N O P Q R S T U V W X Y Z A B C D E F G H I J K

M N O P Q R S T U V W X Y Z A B C D E F G H I J K L

N O P Q R S T U V W X Y Z A B C D E F G H I J K L M

O P Q R S T U V W X Y Z A B C D E F G H I J K L M N

P Q R S T U V W X Y Z A B C D E F G H I J K L M N O

Q R S T U V W X Y Z A B C D E F G H I J K L M N O P

R S T U V W X Y Z A B C D E F G H I J K L M N O P Q

S T U V W X Y Z A B C D E F G H I J K L M N O P Q R

T U V W X Y Z A B C D E F G H I J K L M N O P Q R S

U V W X Y Z A B C D E F G H I J K L M N O P Q R S T

V W X Y Z A B C D E F G H I J K L M N O P Q R S T U

W X Y Z A B C D E F G H I J K L M N O P Q R S T U V

X Y Z A B C D E F G H I J K L M N O P Q R S T U V W

Y Z A B C D E F G H I J K L M N O P Q R S T U V W X

Z A B C D E F G H I J K L M N O P Q R S T U V W X Y

To encipher a message, place the keyword above the plaintext. Once all of the key
characters have been written, start writing the plaintext as the key:
FORTIFICATIONDEFENDTHEEASTWA
DEFENDTHEEASTWALLOFTHECASTLE
Now we take the letter we will be encoding, 'D', and find it on the first column on the
tableau. Then, we move along the 'D' row of the tableau until we come to the column with
the 'F' at the top (The 'F' is the keyword letter for the first 'D'), the intersection is our
ciphertext character, 'I'.
So, the ciphertext for the above plaintext is:
FORTIFICATIONDEFENDTHEEASTWA
DEFENDTHEEASTWALLOFTHECASTLE
ISWXVIBJEXIGGZEQPBIMOIGAKMHE

Javascript Example
This is an JavaScript implementation of the Autokey cipher, enter your plaintext in the text
area provided.
Plaintext

keyword =
fortification

Ciphertext

Other Implementations
To encipher your own messages in python, you can use the pycipher module. To install it,
use pip install pycipher. To encipher messages with the Autokey cipher (or another
cipher, see here for documentation):
>>>from pycipher import Autokey
>>>Autokey('HELLO').encipher('defend the east wall of the castle')
'KIQPBGXMIRDLAAELDHBTSPQFLAPG'
>>>Autokey('HELLO').decipher('KIQPBGXMIRDLAAELDHBTSPQFLAPG')
'DEFENDTHEEASTWALLOFTHECASTLE'

Cryptanalysis
Despite being more secure than the Vigenere cipher, the Autokey cipher is still very easy to
break using automated methods. The reason Autokey is more difficult to break than

Vigenere ciphers is that the key does not repeat, which means the Kasiski test fails, and the
Index of Coincidence can't be used to determine the key length. It's main weakness is that
partial keys can be tested i.e. if you have the first key letter of a length 7 key, then the 1st,
8th, 15th, 22nd etc. characters will be correctly decrypted. This weakness is exploited in
the Autokey cracking guide.

You might also like