Cracking the Atbash cipher
The Atbash cipher is a simple cipher that uses opposite values in the alphabet to transform words. For example, A is equal to Z and C is equal to X.
Getting ready
For this, we will only need the string module.
How to do it…
Since the Atbash cipher works by using the opposite value of a character in the alphabet, we can create a maketrans feature to substitute characters:
import string
input = raw_input("Please enter the value you would like to Atbash Cipher: ")
transform = string.maketrans(
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",
"ZYXWVUTSRQPONMLKJIHGFEDCBAzyxwvutsrqponmlkjihgfedcba")
final = string.translate(input, transform)
print finalHow it works…
After importing the correct module, we request the input from the user for the value they would like encipher into the Atbash cipher:
import string
input = raw_input("Please enter the value you would like to Atbash Ciper: ")Next, we create the maketrans feature to be used. We do this by listing the first...