The Atbash cipher is a substitution cipher originally applied to the Hebrew alphabet. Its name derives from the Hebrew names of some letters. Its cipher alphabet is as follows,
In simple terms, the cipher alphabet is the reverse of the plain alphabet.
If you were writing an algorithm to implement Atbash as your first cipher, you would probably look at the mathematical relationship between the positions of letters in the plain and cipher alphabets. If you number the letter positions of the plain alphabet from 0 to 25, then the letter you substitute is always 25 minus the position of the current letter. A is position 0 and is replaced with Z at position 25 (25 - 0 = 25). B is position 1 and is replaced with Y at position 24 (25 - 1 = 24).
We can also use the arbitrary letter substitution pseudocode if we replace the cipher alphabet with the Atbash cipher alphabet,
cipherAlphabet ← "ZYXWVUTSRQPONMLKJIHGFEDCBA"
plain ← "The secret is out."
upper ← UPPERCASE(plain)
cipherText ← ""
FOR letter ← 0 TO upper.LENGTH - 1
tmpASC ← ASCII CODE OF upper[letter]
IF tmpASC > = 65 AND tmpASC <= 90 THEN
cipherText ← cipherText + cipherAlphabet[tmpASC-65]
cipherText ← cipherText + upper[letter]
One obvious challenge is to implement both algorithms for Atbash.
As with ROT-13, Atbash throws up a few quirky situations where encrypted words make other words. This approach is claimed to be used in a few places in ancient religious texts. You can use word lists and dictionaries to uncover some of these for yourself. Here are a few,