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
- Stream Ciphers
- Difference Between Symmetric and Asymmetric Key Encryption
- Symmetric Encryption Cryptography in Java
- Fernet (symmetric encryption) using Cryptography module in Python
- Caesar Cipher in Cryptography
- Vigenère Cipher
- XOR Cipher
- Rail Fence Cipher - Encryption and Decryption
- Implementation of Affine Cipher
- Columnar Transposition Cipher
- ROT13 cipher
- Implementing Atbash Cipher
- Baconian Cipher
- Keyword Cipher
- Null Cipher
- Latin alphabet cipher
- Hill 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.