Definition: Atbash cipher is a substitution cipher with just one specific key where all the letters are reversed that is A to Z and Z to A. It was originally used to encode the Hebrew alphabets but it can be modified to encode any alphabet.
Relationship to Affine: Atbash cipher can be thought of as a special case of Affine cipher with both the keys being 25, i.e, a = 25 & b = 25
Algorithm: The following key is used in the Atbash algorithm
To encipher a message, find the letter you wish to encipher in the top row, then replace it with the letter in the bottom row.
In the example below, we encipher the message ‘GEEKS FOR GEEKS’. The first letter we wish to encipher is ‘G’, which is above ‘T’, so the first ciphertext letter is ‘T’. The next letter is ‘E’, which is above ‘V’, so that comes next. The whole message is enciphered as:
GEEKS FOR GEEKS TVVPH ULI TVVPH
Similarly if we want to decrypt say ‘TVVPH ULI TVVPH’ we would replace the first letter ‘T’ with ‘G’. The second letter ‘V’ with ‘E’ and so forth substituting all letters including the last one ‘H’ with ‘S’. The deciphered message will be :
TVVPH ULI TVVPH GEEKS FOR GEEKS
The Approach: Here, mapping of every element is done for the key as ‘key-value’ pairs in a dictionary and then it is used as a lookup table whenever you want to encrypt a single character.
Output: TVVPH ULI TVVPH GEEKS FOR GEEKS
Advantages : Since its just an affine cipher with both a = 25 = b we don’t need to write separate functions for encryption and decryption. We can re-use the same function for both purposes.
Analysis : It has one constant key it is the easiest cipher to break and provides almost no security. Anyone can assume that it is atbash and decrypt the message by reversing the letters.
This article is contributed by Palash Nigam . If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Difference between Monoalphabetic Cipher and Polyalphabetic Cipher
- Caesar Cipher in Cryptography
- Vigenère Cipher
- XOR Cipher
- Rail Fence Cipher - Encryption and Decryption
- Implementation of Affine Cipher
- Columnar Transposition Cipher
- ROT13 cipher
- Baconian Cipher
- Keyword Cipher
- Null Cipher
- Latin alphabet cipher
- Polybius Square Cipher
- Hill Cipher
- Playfair Cipher with Examples
- Vernam Cipher in Cryptography
- Bifid Cipher in Cryptography
- Substitution Cipher
- Feistel Cipher
- Autokey Cipher | Symmetric Ciphers