What the Atbash cipher is
Atbash replaces each letter with the letter at the same distance from the other end of the alphabet. The first letter swaps with the last, the second with the second to last, and so on. It comes from Hebrew, where Aleph (א) swaps with Tav (ת) and Beth (ב) with Shin (ש). Those four letters, A-T-B-Sh, give the cipher its name.
It is one of the oldest ciphers we know of, because it appears in the Hebrew Bible, in the Book of Jeremiah, which dates from around the 6th century BC.
The alphabet in Hebrew and in English
א Aleph ↔ ת Tav ב Beth ↔ ש Shin ג Gimel ↔ ר Resh ד Dalet ↔ ק Qoph ...
Applied to the English alphabet, the same rule gives this table:
| Plain | A B C D E F G H I J K L M N O P Q R S T U V W X Y Z |
|---|---|
| Atbash | Z Y X W V U T S R Q P O N M L K J I H G F E D C B A |
HELLO WORLD → SVOOL DLIOW
Atbash in the Book of Jeremiah
Two passages in Jeremiah use Atbash to write a name in disguise.
Sheshach for Babylon
The word Sheshach appears in Jeremiah 25:26 and 51:41. In the King James Version they read:
"...and the king of Sheshach shall drink after them." (Jeremiah 25:26)
"How is Sheshach taken! and how is the praise of the whole earth surprised!" (Jeremiah 51:41)
In Hebrew, Sheshach is written ששך (Shin, Shin, Kaf). Apply Atbash: Shin becomes Beth and Kaf becomes Lamed, which gives בבל, Babel, the Hebrew name for Babylon. Jeremiah 51:41 goes on to name Babylon openly in its second half, which is one reason readers have long connected the two.
Leb Kamai for the Chaldeans
Jeremiah 51:1 contains the phrase לב קמי, leb kamai, which means "the heart of those who rise up against me". The King James Version translates it literally: "against them that dwell in the midst of them that rise up against me". Decoded with Atbash, the same letters give כשדים, Kasdim, the Chaldeans, the people who ruled Babylon.
Why a prophet would use a cipher
Scholars disagree about why these passages use Atbash. The main explanations are:
- Protection. Jeremiah wrote while Babylon dominated Judah, and a disguised name might have made a prophecy of its fall less dangerous. Against this, Babylon is named openly many times in the same book, including in the same verse as Sheshach.
- Symbolism. Scott Noegel and others have argued that reversing the alphabet suits passages about the reversal of power, where a mighty empire is brought down.
- Wordplay. The disguised names may simply be a literary device for readers who knew the trick. Leb kamai works both as a phrase with its own meaning and as a hidden name.
None of these can be proved, and more than one may be true.
How the Atbash cipher works
Number the letters A = 1 to Z = 26. A letter at position n becomes the letter at position 27 − n. Here is SECRET:
| Letter | Position | 27 − position | Atbash |
|---|---|---|---|
| S | 19 | 8 | H |
| E | 5 | 22 | V |
| C | 3 | 24 | X |
| R | 18 | 9 | I |
| E | 5 | 22 | V |
| T | 20 | 7 | G |
SECRET becomes HVXIVG.
The same step decodes
Atbash is its own inverse. Applying it twice gives back the original, so encoding and decoding are the same operation:
CIPHER → XRKSVI → CIPHER
Atbash is sometimes confused with ROT13, which also decodes itself. They are different ciphers. ROT13 shifts every letter 13 places along the alphabet, while Atbash mirrors the alphabet, so A becomes N in ROT13 and Z in Atbash. You can compare them with the Atbash tool and the ROT13 tool.
How to break Atbash
Atbash has no key. Once someone suspects it, they can decode the message at once, so its only protection is that the reader doesn't know the method. It is easy to spot:
- E is the most common letter in English, and in Atbash it becomes V. If about one letter in eight of a long ciphertext is V, Atbash is a good guess.
- THE, the most common English word, becomes GSV. A ciphertext full of GSV is almost certainly Atbash.
- Letter patterns survive. Double letters stay double, so HELLO becomes SVOOL.
Like every single-alphabet substitution, it gives no real protection. Use it for puzzles and teaching only.
Other letter techniques in Hebrew texts
Albam
Albam is a related Hebrew substitution. It splits the 22-letter alphabet into two halves of 11 and swaps each letter with the one in the same place in the other half: Aleph with Lamed, Beth with Mem, and so on. The name comes from those first pairs, A-L-B-M.
Gematria
Every Hebrew letter also has a number value, and gematria adds up the values of a word. The word chai (חי), meaning life, is Het (8) plus Yod (10), which makes 18. That is why gifts in Jewish tradition are often given in multiples of 18. Gematria is a way of reading meaning into numbers rather than a cipher.
Acrostics and notarikon
Psalm 119 and most of the Book of Lamentations are alphabetic acrostics, where successive verses or sections start with successive letters of the alphabet. Notarikon treats each letter of a word as the first letter of another word, and later Kabbalistic readings of scripture used it widely. Neither hides a message the way Atbash does.
Atbash today
Atbash turns up in escape rooms, geocaches, puzzle hunts and alternate reality games, usually as an easy first cipher. In Dan Brown's novel The Da Vinci Code, the characters use Atbash to turn the word Baphomet into Sophia. It is also a common beginner programming exercise, because the whole cipher fits in a few lines.
JavaScript
function atbash(text) {
return text.replace(/[a-z]/gi, (char) => {
const base = char <= 'Z' ? 65 : 97;
return String.fromCharCode(base + 25 - (char.charCodeAt(0) - base));
});
}
atbash('HELLO WORLD'); // SVOOL DLIOW
atbash('SVOOL DLIOW'); // HELLO WORLDPython
def atbash(text):
result = []
for char in text:
if char.isascii() and char.isalpha():
base = ord('A') if char.isupper() else ord('a')
result.append(chr(base + 25 - (ord(char) - base)))
else:
result.append(char)
return ''.join(result)
print(atbash('HELLO WORLD')) # SVOOL DLIOW Try it on Cipher Utility
Further reading
- Caesar Cipher Explained: Your First Cipher A 2,000-year-old letter shift and the easiest way into cryptography.
- From Caesar to Enigma: A History of Military Cryptography Two thousand years of military codes and the people who broke them.
- The Vigenère Cipher: 300 Years of 'Unbreakable' Security A keyword cipher that held out for three centuries, and how it fell.