# Autokey cipher

- Description
- Algorithm
- Implementation

Like in other polyalphabetic substitution ciphers, the autokey cipher algorithm is about changing plaintext letters based on secret key letters. Each letter of the message is shifted along some alphabet positions. The number of positions is equal to the place in the alphabet of the current key letter.

To simplify calculations, one can use a table which contains in subsequent row alphabets with letters shifted along increasingly larger number of positions. The table is called tabula recta.

Unlike in other similar ciphers, after using all of secret key letters, the algorithm doesn't go back to its first letter but starts to take plaintext letters as new key letters.

For example, after encryption two words Opinio communis using the secret key Ab ovo one receives:

Plaintext: | OPINIOCOMMUNIS |

Key: | ABOVOOPINIOCOM |

Ciphertext: | OQWIWCRWZUIPWE |

## Security of the autokey cipher

Due to avoid repetition of the same secret key letters, the cipher is resistant to attacks based on dividing ciphertext into parts corresponding to subsequent secret key characters. However its weakness is that all key characters create words and sentences which in addition are the same as in plaintext.

To break the cipher, the intruder should try to guess some parts of plaintext (for example trying some common sequences of letters). Comparing them to plaintext allows to receive some characters of the secret key. One should try to find such letters which result in disclosure of correct words among the secret key characters.