Atbash Cipher Examples - Learn Atbash Cipher with Interactive Code Tutorials

Master the Atbash cipher with comprehensive Atbash cipher examples and interactive Atbash cipher tools. Explore Atbash cipher code examples, Hebrew Atbash cipher examples, and practical Atbash cipher implementations.

Interactive Atbash Cipher Examples

Learn Atbash cipher through step-by-step Atbash cipher examples from beginner to advanced level

Simple Word - HELLO

beginner
HELLO
SVOOL

H→S, E→V, L→O, L→O, O→L. Each letter in this Atbash cipher example maps to its mirror position in the alphabet.

Common Word - WORLD

beginner
WORLD
DLIOW

W→D, O→L, R→I, L→O, D→W. Notice how the Atbash cipher transformation is consistent and reversible.

The Word ATBASH

beginner
ATBASH
ZGYZHS

A→Z, T→G, B→Y, A→Z, S→H, H→S. The Atbash cipher's own name demonstrates the Atbash cipher principle.

Short Sentence

intermediate
MEET AT DAWN
NVVG ZG WZDA

Complete Atbash cipher sentence showing how spaces are preserved while letters transform according to the Atbash cipher mirror principle.

Mixed Case Text

intermediate
Attack at Midnight
Zggzxp zg Nrmmrtsg

Demonstrates how Atbash cipher preserves case while transforming letters. This Atbash cipher example shows uppercase remains uppercase.

Complex Message

advanced
The secret is hidden in the ancient text!
Gsv hvxivg rh sroovn rm gsv zmxrvmg gvcg!

Full Atbash cipher sentence with punctuation showing practical application of Atbash cipher in message encoding and Atbash cipher usage.

Hebrew Atbash Cipher - Biblical Cipher Examples

Historical Hebrew Atbash cipher examples from biblical texts showing real-world Atbash cipher usage

Jeremiah 25:26 - Sheshach

Jeremiah 25:26
ששך
Transliteration: Sheshach
בבל (Babel/Babylon)
English: (Babel/Babylon)

The most famous biblical Atbash cipher example where 'Sheshach' (ששך) is Atbash cipher for 'Babel' (בבל), referring to Babylon. This Atbash cipher demonstrates ancient Hebrew cryptography.

Jeremiah 51:1 - Leb Kamai

Jeremiah 51:1
לבקמי
Transliteration: Leb-Kamai
כשדים (Kasdim/Chaldeans)
English: (Kasdim/Chaldeans)

'Leb-Kamai' (לבקמי) decodes using Atbash cipher to 'Kasdim' (כשדים), the Hebrew name for the Chaldeans/Babylonians. Another classic Atbash cipher example.

Hebrew Alphabet Principle

Hebrew Alphabet
אלף תו בית שין
Transliteration: Aleph Tav Beit Shin
A-T-B-SH demonstrates the cipher principle
English: demonstrates

Atbash cipher gets its name from pairing the first and last letters: Aleph-Tav, Beit-Shin (A-T-B-SH). This explains the Atbash cipher terminology and Hebrew alphabet principle.

Atbash Cipher Programming Implementations

Production-ready Atbash cipher code examples in Python and JavaScript with detailed Atbash cipher explanations

Python Implementation

python
def atbash_cipher(text):
    """
    Encode/decode text using Atbash cipher
    """
    result = ""
    
    for char in text:
        if char.isalpha():
            # Handle uppercase letters
            if char.isupper():
                # A=0, Z=25, so Z-A = 25-0 = 25
                position = ord(char) - ord('A')
                new_position = 25 - position
                result += chr(ord('A') + new_position)
            # Handle lowercase letters
            else:
                position = ord(char) - ord('a')
                new_position = 25 - position
                result += chr(ord('a') + new_position)
        else:
            # Keep non-alphabetic characters as-is
            result += char
    
    return result

# Example usage
original = "HELLO WORLD"
encoded = atbash_cipher(original)
decoded = atbash_cipher(encoded)  # Atbash is self-inverse

print(f"Original: {original}")
print(f"Encoded:  {encoded}")
print(f"Decoded:  {decoded}")

Complete Python Atbash cipher implementation with support for both uppercase and lowercase letters. This Atbash cipher function is self-inverse, demonstrating the Atbash cipher's symmetric property.

JavaScript Implementation

javascript
function atbashCipher(text) {
    /**
     * Encode/decode text using Atbash cipher
     * @param {string} text - Input text to transform
     * @returns {string} - Transformed text
     */
    return text
        .split('')
        .map(char => {
            if (/[A-Z]/.test(char)) {
                // Handle uppercase letters (A=65, Z=90)
                const position = char.charCodeAt(0) - 65;
                const newPosition = 25 - position;
                return String.fromCharCode(65 + newPosition);
            } else if (/[a-z]/.test(char)) {
                // Handle lowercase letters (a=97, z=122)
                const position = char.charCodeAt(0) - 97;
                const newPosition = 25 - position;
                return String.fromCharCode(97 + newPosition);
            }
            // Keep non-alphabetic characters unchanged
            return char;
        })
        .join('');
}

// Example usage with arrow function syntax
const encode = text => atbashCipher(text);
const decode = text => atbashCipher(text); // Same function!

// Test the implementation
const message = "Attack at Dawn";
const encoded = encode(message);
const decoded = decode(encoded);

console.log(`Original: ${message}`);
console.log(`Encoded:  ${encoded}`);
console.log(`Decoded:  ${decoded}`);

Modern JavaScript Atbash cipher implementation using ES6 features. Demonstrates functional programming approach with map/split/join for Atbash cipher encoding and decoding.

Advanced Python with Unicode

python
import string
from typing import Dict, Optional

class AtbashCipher:
    """
    Advanced Atbash cipher implementation with multiple character sets
    """
    
    def __init__(self, include_numbers: bool = False, include_special: bool = False):
        self.include_numbers = include_numbers
        self.include_special = include_special
        self._create_mappings()
    
    def _create_mappings(self) -> None:
        """Create character mapping dictionaries"""
        self.mappings: Dict[str, str] = {}
        
        # Letters
        upper = string.ascii_uppercase
        lower = string.ascii_lowercase
        self.mappings.update({
            char: upper[25 - i] for i, char in enumerate(upper)
        })
        self.mappings.update({
            char: lower[25 - i] for i, char in enumerate(lower)
        })
        
        # Numbers (optional)
        if self.include_numbers:
            digits = string.digits
            self.mappings.update({
                char: digits[9 - i] for i, char in enumerate(digits)
            })
        
        # Special characters (optional)
        if self.include_special:
            special = '!@#$%^&*()_+-=[]{}|;':",./<>?'
            reversed_special = special[::-1]
            self.mappings.update({
                char: reversed_special[i] for i, char in enumerate(special)
            })
    
    def transform(self, text: str) -> str:
        """Transform text using Atbash cipher"""
        return ''.join(
            self.mappings.get(char, char) for char in text
        )
    
    def encode(self, text: str) -> str:
        """Encode text (alias for transform)"""
        return self.transform(text)
    
    def decode(self, text: str) -> str:
        """Decode text (alias for transform - Atbash is self-inverse)"""
        return self.transform(text)

# Usage examples
cipher = AtbashCipher()
advanced_cipher = AtbashCipher(include_numbers=True, include_special=True)

text = "Hello, World! 123"
print(f"Original: {text}")
print(f"Basic:    {cipher.encode(text)}")
print(f"Advanced: {advanced_cipher.encode(text)}")

Production-ready Python Atbash cipher class with support for numbers, special characters, and proper error handling. Advanced Atbash cipher implementation for real-world applications.

Learning Atbash Through Examples

The Atbash cipher is best understood through practical examples that demonstrate its principles and applications. This comprehensive tutorial provides examples ranging from simple words to complex implementations.

Basic Examples

Simple Word Transformations

HELLO → SVOOL

  • H (8th letter) → S (19th letter)
  • E (5th letter) → V (22nd letter)
  • L (12th letter) → O (15th letter)
  • L (12th letter) → O (15th letter)
  • O (15th letter) → L (12th letter)

WORLD → DLIOW The transformation demonstrates the consistent mirror mapping where each letter's position is subtracted from 26 (in a 1-based system) or 25 (in a 0-based system).

Progressive Difficulty Levels

Beginner Level

  • Single words: ATBASH → ZGYZHS
  • Simple phrases: MEET AT DAWN → NVVG ZG WZDA
  • Mixed case preservation: Attack → Zggzxp

Intermediate Level

  • Complete sentences with punctuation
  • Numbers and special characters (when enabled)
  • Real-world message examples

Advanced Level

  • Paragraph-length texts
  • Mixed content types
  • Historical document analysis

Hebrew Examples and Biblical References

The Name "Atbash"

The cipher gets its name from the Hebrew alphabet pairing:

  • Aleph (א) + Tav (ת) = AT
  • Beth (ב) + Shin (ש) = BASH

Jeremiah 25
- Sheshach

Original Hebrew: ששך (Sheshach)
Atbash Decoded: בבל (Babel/Babylon)

This is the most famous biblical example where the prophet Jeremiah uses Atbash to encode the name of Babylon, possibly to avoid directly naming the powerful empire.

Jeremiah 51
- Leb Kamai

Original Hebrew: לב קמי (Leb Kamai)
Atbash Decoded: כשדים (Kasdim/Chaldeans)

Another example from Jeremiah where "Leb Kamai" (literally "heart of those who rise up against me") encodes "Kasdim" (Chaldeans).

Programming Implementations

Python Implementation

def atbash_cipher(text):
    """
    Encode/decode text using Atbash cipher
    """
    result = ""
    
    for char in text:
        if char.isalpha():
            if char.isupper():
                # A=0, Z=25, so Z-A = 25-0 = 25
                position = ord(char) - ord('A')
                new_position = 25 - position
                result += chr(ord('A') + new_position)
            else:
                position = ord(char) - ord('a')
                new_position = 25 - position
                result += chr(ord('a') + new_position)
        else:
            result += char
    
    return result

# Example usage
message = "The secret is hidden"
encoded = atbash_cipher(message)
decoded = atbash_cipher(encoded)  # Atbash is self-inverse

print(f"Original: {message}")
print(f"Encoded:  {encoded}")
print(f"Decoded:  {decoded}")

JavaScript Implementation

function atbashCipher(text) {
    return text
        .split('')
        .map(char => {
            if (/[A-Z]/.test(char)) {
                const position = char.charCodeAt(0) - 65;
                const newPosition = 25 - position;
                return String.fromCharCode(65 + newPosition);
            } else if (/[a-z]/.test(char)) {
                const position = char.charCodeAt(0) - 97;
                const newPosition = 25 - position;
                return String.fromCharCode(97 + newPosition);
            }
            return char;
        })
        .join('');
}

// Example usage
const message = "Attack at Dawn";
const encoded = atbashCipher(message);
const decoded = atbashCipher(encoded);

console.log(`Original: ${message}`);
console.log(`Encoded:  ${encoded}`);
console.log(`Decoded:  ${decoded}`);

Advanced Python Class

import string
from typing import Dict

class AtbashCipher:
    def __init__(self, include_numbers=False, include_special=False):
        self.include_numbers = include_numbers
        self.include_special = include_special
        self._create_mappings()
    
    def _create_mappings(self):
        self.mappings = {}
        
        # Letters
        upper = string.ascii_uppercase
        lower = string.ascii_lowercase
        self.mappings.update({
            char: upper[25 - i] for i, char in enumerate(upper)
        })
        self.mappings.update({
            char: lower[25 - i] for i, char in enumerate(lower)
        })
        
        # Numbers (optional)
        if self.include_numbers:
            digits = string.digits
            self.mappings.update({
                char: digits[9 - i] for i, char in enumerate(digits)
            })
    
    def transform(self, text):
        return ''.join(
            self.mappings.get(char, char) for char in text
        )

Mathematical Foundation

The Atbash transformation can be expressed mathematically:

For a letter at position i (0-based indexing):

encoded_position = (alphabet_length - 1) - i

For English alphabet (26 letters):

encoded_position = 25 - i

This formula works for any alphabet length, making it adaptable to different languages.

Educational Applications

Classroom Activities

  1. Letter Mapping Exercises: Students create their own alphabet transformation charts
  2. Historical Analysis: Examining biblical texts for cipher patterns
  3. Programming Challenges: Implementing the cipher in different languages
  4. Cryptanalysis Practice: Learning to detect and break simple ciphers

Research Projects

  • Analyzing frequency patterns in Atbash-encoded texts
  • Comparing Atbash with other substitution ciphers
  • Historical significance of biblical cryptography
  • Development of cipher detection algorithms

Practical Exercises

Exercise 1: Basic Encoding

Encode these words using Atbash:

  • SECRET
  • CIPHER
  • ANCIENT

Exercise 2: Hebrew Examples

Research and analyze these biblical references:

  • Jeremiah 25
    (Sheshach)
  • Jeremiah 51
    (Leb Kamai)
  • Jeremiah 51
    (Sheshach variant)

Exercise 3: Implementation Challenge

Write a program that:

  1. Accepts user input
  2. Applies Atbash transformation
  3. Detects if input is already Atbash-encoded
  4. Provides confidence scoring

Historical Significance

The Atbash cipher represents one of humanity's earliest encryption methods, demonstrating that the need for secure communication has existed for millennia. Its appearance in biblical texts shows that cryptography was not merely a military tool but also had religious and literary applications.

Modern Relevance

While not secure by modern standards, Atbash remains valuable for:

  • Educational purposes in cryptography courses
  • Puzzle and game development
  • Historical text analysis
  • Understanding the evolution of encryption methods

The simplicity of Atbash makes it an excellent introduction to cryptographic concepts, serving as a stepping stone to more complex ciphers and modern encryption algorithms.