Substitution Ciphers

The easiest way to hide information

← All Lessons Next: Hacking Caesar Cipher →

Introduction to Substitution Ciphers

Substitution ciphers are among the oldest and simplest encryption techniques. They work by replacing each letter in the plaintext with another letter or symbol according to a fixed rule.

i

A cipher is a method of transforming text to conceal its meaning, while encryption is the process of applying that cipher.

The Caesar Cipher

The Caesar cipher, named after Julius Caesar who reportedly used it to communicate with his generals, is one of the simplest and most widely known encryption techniques.

How it Works

In a Caesar cipher, each letter in the plaintext is shifted a certain number of places down the alphabet. For example, with a shift of 3:

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
↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
D E F G H I J K L M N O P Q R S T U V W X Y Z A B C

Plaintext: HELLO WORLD

Ciphertext: KHOOR ZRUOG

Try It Yourself

Result:

KHOOR ZRUOG

ROT13 - A Special Case

ROT13 (rotate by 13 places) is a special case of the Caesar cipher where the shift is fixed at 13. What makes ROT13 interesting is that applying it twice returns the original text, since 13 + 13 = 26, which is the length of the English alphabet.

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
↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
N O P Q R S T U V W X Y Z A B C D E F G H I J K L M

Plaintext: HELLO WORLD

ROT13 Ciphertext: URYYB JBEYQ

Try ROT13

Result:

URYYB JBEYQ

Historical Significance

Substitution ciphers like the Caesar cipher were used for thousands of years for secure communication. Julius Caesar used a shift of 3 to protect military messages. If the message was intercepted, it would appear as gibberish to the enemy.

Did You Know?

ROT13 was widely used in online forums in the early days of the internet to hide spoilers, punchlines, and offensive content. It provided a simple way to obscure text while still making it accessible to those who wanted to read it.

Weaknesses of Simple Substitution Ciphers

While easy to use, substitution ciphers like Caesar and ROT13 have significant weaknesses:

  • Limited key space (only 25 possible shifts in Caesar cipher)
  • Vulnerable to frequency analysis (letters like 'E', 'T', and 'A' appear more frequently in English)
  • Patterns in the plaintext remain in the ciphertext

In the next lesson, we'll explore how to break a Caesar cipher using these weaknesses.

Summary

Key Points

  • Substitution ciphers replace each letter with another letter according to a fixed rule
  • The Caesar cipher shifts each letter a fixed number of positions in the alphabet
  • ROT13 is a special case where the shift is 13 places
  • These ciphers are simple but not secure for modern use