Logo

MonoCalc

/

Substitution Cipher

Encode/Decode

Substitution Key 26/26

Key strength:

100% randomness

PlainABCDEFGHIJKLMNOPQRSTUVWXYZ
CipherQWERTYUIOPASDFGHJKLZXCVBNM

0 letters

Inverse (decrypt) key:

KXVMCNOPHQRSZYIJADLEGWBUFT

About This Tool

🔀 Substitution Cipher – Encode and Decode Text

A substitution cipher is one of the oldest and most studied forms of classical cryptography. Every letter in the plaintext is systematically replaced by a corresponding letter (or symbol) according to a fixed key — the substitution alphabet. Unlike the Caesar cipher, which simply shifts every letter by a fixed amount, a monoalphabetic substitution cipher uses an arbitrary permutation of the 26-letter alphabet, giving 26! ≈ 4 × 10²⁶ possible keys.

📖 How It Works

The key is a 26-character string where each position maps the standard alphabet letter to its cipher equivalent:

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

"Hello World" → "Itssg Vgksr"

Non-alphabetic characters (spaces, punctuation, digits) pass through unchanged by default, preserving the structure of the original message. Case is also preserved — a lowercase h maps to a lowercase cipher letter, while an uppercase H maps to the uppercase cipher letter.

🔓 Decryption

Decryption uses the inverse key — a mapping computed by reversing the encryption key. For each cipher letter, the inverse key tells you which plaintext letter it came from. The tool computes and displays the inverse key automatically, so you never need to calculate it manually.

🎲 Key Generation

A valid substitution key must contain each of the 26 letters exactly once — mathematically, it is a permutation (bijection) of the alphabet. The tool validates your key in real time and highlights duplicates or missing letters. Click Random Key to instantly generate a cryptographically shuffled key using the Fisher–Yates algorithm.

📊 Frequency Analysis

The monoalphabetic substitution cipher is vulnerable to frequency analysis — the primary technique for breaking it. In any sufficiently long English ciphertext, the most common letters tend to correspond to the most common English letters:

RankLetterEnglish Frequency
1

E

12.7%
2

T

9.1%
3

A

8.2%
4

O

7.5%
5

I

7.0%
6

N

6.7%
7

S

6.3%
8

H

6.1%

Enable the Frequency Analysis toggle to compare the letter distribution of your ciphertext against the standard English baseline. Blue bars represent ciphertext frequencies; gray bars represent expected English frequencies.

🏛️ Historical Context

Substitution ciphers have been used for millennia. The Atbash cipher (Hebrew, ~600 BCE) reverses the alphabet. Julius Caesar used a shift of 3 — a special case of substitution. ROT13 (shift of 13) is another well-known special case where encryption and decryption are identical. The Vigenère cipher later extended the idea to polyalphabetic substitution to resist frequency analysis.

The monoalphabetic substitution cipher was famously broken by the 9th-century Arab scholar Al-Kindi, who first described frequency analysis. Edgar Allan Poe's short story The Gold-Bug (1843) popularised cipher solving for a general audience.

⚠️ Security Notice

The substitution cipher is not cryptographically secure and should never be used to protect sensitive data. It is purely educational and suitable for puzzles, escape rooms, and learning classical cryptanalysis. For real security, use modern standards like AES-256.

Frequently Asked Questions

Is the Substitution Cipher free?

Yes, Substitution Cipher is totally free :)

Can I use the Substitution Cipher offline?

Yes, you can install the webapp as PWA.

Is it safe to use Substitution Cipher?

Yes, any data related to Substitution Cipher only stored in your browser (if storage required). You can simply clear browser cache to clear all the stored data. We do not store any data on server.

How does the Substitution Cipher tool work?

Enter your text, provide a 26-character substitution key (each letter of A–Z mapped to a unique cipher letter), and choose Encrypt or Decrypt. The tool replaces each letter in your input with the corresponding letter from the key, preserving case, spaces, and punctuation.

What is a valid substitution key?

A valid key must be exactly 26 characters long, contain each letter A–Z exactly once (no duplicates or omissions), and be purely alphabetic. The tool validates in real time and highlights any errors in the key editor.

How do I decrypt a message encrypted with this tool?

Switch to Decrypt mode and enter the same key used during encryption. The tool automatically computes the inverse mapping and recovers the original plaintext.

Is the substitution cipher secure?

No. The monoalphabetic substitution cipher is vulnerable to frequency analysis — an attacker can compare letter frequencies in the ciphertext against standard English frequencies (E=12.7%, T=9.1%, etc.) to recover the key. It is suitable for puzzles and education only.

What does the Random Key button do?

It generates a cryptographically shuffled 26-letter key where each letter appears exactly once. This is useful for quick experiments without manually crafting a key.

What is the Character Mapping Table?

The mapping table shows the full A–Z to cipher-letter correspondence for the current key. It updates live as you edit the key and makes it easy to verify or debug your substitution mapping at a glance.