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 Vigenère in 1586. In general, more secure than the Vigenere cipher.
Plaintext = "HELLO" Autokey = N Ciphertext = "ULPWZ"
Plaintext = "GEEKSFORGEEKS" Autokey = P Ciphertext = "VKIOCXTFXKIOC"
In this cipher, the key is a stream of subkeys which is used to encrypt the corresponding character in the plaintext.
As shown, the autokey is added at the first of the subkeys.
Let's explain Example 1: Given plain text is : H E L L O Key is : N H E L L Let's encrypt: Plain Text(P) : H E L L O Corresponding Number: 7 4 11 11 14 Key(K) : N H E L L Corresponding Number: 13 7 4 11 11 --------------------- Applying the formula: 20 11 15 22 25 Corresponding Letters are : U L P W Z Hence Ciphertext is: ULPWZ Let's decrypt: Cipher Text(C) : U L P W Z Key(K) : N H E L L --------------------- Applying the formula: H E L L O Hence Plaintext is: HELLO
Here’s the java code for Autokey Cipher.
Output: Plaintext : HELLO Encrypted : ULPWZ Decrypted : HELLO
- Traditional Symmetric Ciphers
- Difference between Monoalphabetic Cipher and Polyalphabetic Cipher
- Difference between AES and DES ciphers
- XOR Cipher
- Feistel Cipher
- Substitution Cipher
- Hill Cipher
- Null Cipher
- Vigenère Cipher
- Keyword Cipher
- Baconian Cipher
- ROT13 cipher
- Implementing Atbash Cipher
- Bifid Cipher in Cryptography
- Vernam Cipher in Cryptography
- Playfair Cipher with Examples
- Latin alphabet cipher
- Caesar Cipher in Cryptography
- Columnar Transposition Cipher
- Implementation of Affine Cipher
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.