Repository navigation
Classical Ciphers
Last reviewed: 2026-10-02
Important
Historical and educational content. Ordinary classical ciphers are unsuitable for real data. A true one-time pad has strict secrecy assumptions and no built-in authentication. For protecting information, use the modern algorithms in algorithms.md and applied-crypto.md.
โ Alternative Alphabets ยท ๐ Classical Index ยท Building Your Own Alphabet โ
Substitution master chart, transposition, Playfair, Vigenรจre and its variants, and the one-time pad.
On this page:
- Classical Substitution Master Chart
- Transposition Ciphers
- Polygraphic: The Playfair Cipher
- Polyalphabetic: The Vigenรจre Cipher
- The One-Time Pad
Substitution ciphers replace each letter with another symbol while keeping its position. One chart, eight systems:
| Letter | A1Z26 | ROT13 | Atbash | QWERTY โ1 | Polybius | Tap code | Baconian | Binary (5-bit) |
|---|---|---|---|---|---|---|---|---|
| A | 1 | N | Z | S | 11 | ยท ยท | aaaaa |
00000 |
| B | 2 | O | Y | N | 12 | ยท ยทยท | aaaab |
00001 |
| C | 3 | P | X | V | 13 | ยท ยทยทยท | aaaba |
00010 |
| D | 4 | Q | W | F | 14 | ยท ยทยทยทยท | aaabb |
00011 |
| E | 5 | R | V | R | 15 | ยท ยทยทยทยทยท | aabaa |
00100 |
| F | 6 | S | U | G | 21 | ยทยท ยท | aabab |
00101 |
| G | 7 | T | T | H | 22 | ยทยท ยทยท | aabba |
00110 |
| H | 8 | U | S | J | 23 | ยทยท ยทยทยท | aabbb |
00111 |
| I | 9 | V | R | O | 24 | ยทยท ยทยทยทยท | abaaa |
01000 |
| J | 10 | W | Q | K | 24 | ยทยท ยทยทยทยทยท | abaab |
01001 |
| K | 11 | X | P | L | 25 | ยท ยทยทยท | ababa |
01010 |
| L | 12 | Y | O | A | 31 | ยทยทยท ยท | ababb |
01011 |
| M | 13 | Z | N | Z | 32 | ยทยทยท ยทยท | abbaa |
01100 |
| N | 14 | A | M | M | 33 | ยทยทยท ยทยทยท | abbab |
01101 |
| O | 15 | B | L | P | 34 | ยทยทยท ยทยทยทยท | abbba |
01110 |
| P | 16 | C | K | Q | 35 | ยทยทยท ยทยทยทยทยท | abbbb |
01111 |
| Q | 17 | D | J | W | 41 | ยทยทยทยท ยท | baaaa |
10000 |
| R | 18 | E | I | T | 42 | ยทยทยทยท ยทยท | baaab |
10001 |
| S | 19 | F | H | D | 43 | ยทยทยทยท ยทยทยท | baaba |
10010 |
| T | 20 | G | G | Y | 44 | ยทยทยทยท ยทยทยทยท | baabb |
10011 |
| U | 21 | H | F | I | 45 | ยทยทยทยท ยทยทยทยทยท | babaa |
10100 |
| V | 22 | I | E | B | 51 | ยทยทยทยทยท ยท | babab |
10101 |
| W | 23 | J | D | E | 52 | ยทยทยทยทยท ยทยท | babba |
10110 |
| X | 24 | K | C | C | 53 | ยทยทยทยทยท ยทยทยท | babbb |
10111 |
| Y | 25 | L | B | U | 54 | ยทยทยทยทยท ยทยทยทยท | bbaaa |
11000 |
| Z | 26 | M | A | X | 55 | ยทยทยทยทยท ยทยทยทยทยท | bbaab |
11001 |
How each column works:
-
A1Z26: Letter position in the alphabet.
HELLOโ8-5-12-12-15. -
ROT13 / Caesar: Shift the alphabet by n (ROT13 uses 13). Applying ROT13 twice returns the original.
HELLOโURYYB. -
Atbash: Mirror the alphabet (AโZ, BโY). Originally used with the Hebrew alphabet.
HELLOโSVOOL. - QWERTY โ1: Each letter becomes the key to its right on the same row, wrapping at row ends (PโQ, LโA, MโZ). Wrap conventions vary between puzzles; some include punctuation keys.
- Polybius square: Letters placed in a 5ร5 grid and written as row/column coordinates. I and J share a cell.
- Tap code: Same grid idea, tapped as two groups (row, then column). Used by U.S. POWs in Vietnam. C and K share a cell, so J gets its own.
-
Baconian: Francis Bacon's 5-symbol
a/bcode (a binary code in disguise). Shown here in the modern 26-letter form; Bacon's original merged I/J and U/V. Thea/bcan be hidden as two typefaces, so the message is steganographic (hidden in plain sight). - Pigpen: Letters replaced by fragments of tic-tac-toe and X grids (with and without dots). It is a graphical alphabet, so it is not shown in the table.
Polybius square and tap code grids:
Polybius (I/J) Tap code (C/K)
1 2 3 4 5 1 2 3 4 5
1 A B C D E 1 A B C D E
2 F G H I K 2 F G H I J
3 L M N O P 3 L M N O P
4 Q R S T U 4 Q R S T U
5 V W X Y Z 5 V W X Y Z
Transposition ciphers keep every letter but scramble the order. Letter frequency is unchanged (a clue that you are looking at a transposition, not a substitution).
Write the message in a zig-zag across n rails, then read each rail left to right. With 3 rails:
W . . . E . . . C . . . R . . .
. E . R . D . S . O . E . E . .
. . A . . . I . . . V . . . D .
WEAREDISCOVERED โ WECRERDSOEEAIVD
Write the message in rows under a keyword, then read the columns in the alphabetical order of the keyword's letters. With keyword ZEBRA (column order A=1, B=2, E=3, R=4, Z=5):
Z E B R A
---------
A T T A C
K A T D A
W N
ATTACKATDAWN โ CATTTANADAKW
Combining substitution and transposition (as in the WWI German ADFGVX cipher) can frustrate attacks on either stage alone. Composition does not automatically guarantee security; the details matter.
Playfair (Charles Wheatstone, 1854, promoted by Lord Playfair) encrypts pairs of letters with a 5ร5 keyed square (I/J combined). Because it works on digraphs, single-letter frequency analysis no longer applies directly. Key square for keyword MONARCHY:
M O N A R
C H Y B D
E F G I K
L P Q S T
U V W X Z
Rules (split the plaintext into pairs; insert X between doubled letters and pad an odd final letter):
-
Same row: Take the letter to the right of each (wrapping).
ARโRM - Same column: Take the letter below each (wrapping).
- Rectangle: Take the letter in the same row but in the other letter's column.
The Vigenรจre cipher encrypts using a series of interwoven Caesar ciphers chosen by the letters of a keyword. Repeat the keyword over the message, then use the Tabula Recta (a 26ร26 grid of shifted alphabets) to find the intersection of the plaintext letter and the key letter. Mathematically, C = (P + K) mod 26.
Tabula recta (excerpt):
| Key โ / Plain โ | A | B | C | D | E | F | G | H | I | J | K | L | M |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| A | A | B | C | D | E | F | G | H | I | J | K | L | M |
| B | B | C | D | E | F | G | H | I | J | K | L | M | N |
| C | C | D | E | F | G | H | I | J | K | L | M | N | O |
| D | D | E | F | G | H | I | J | K | L | M | N | O | P |
| E | E | F | G | H | I | J | K | L | M | N | O | P | Q |
| K | K | L | M | N | O | P | Q | R | S | T | U | V | W |
| Y | Y | Z | A | B | C | D | E | F | G | H | I | J | K |
Example:
| Role | Position 1 | Position 2 | Position 3 | Position 4 | Position 5 | Position 6 |
|---|---|---|---|---|---|---|
| Plaintext | H | I | D | D | E | N |
| Keyword | K | E | Y | K | E | Y |
| Ciphertext | R | M | B | N | I | L |
-
Flattened frequencies: Because the shift changes with the key,
Eencrypts to several different letters. -
Same letter, different output: The double
DinHIDDENbecameBandN. - Key length matters: Security scales with the length and randomness of the keyword. A uniformly random, independent, secret key as long as the message, used once, becomes a one-time pad (The One-Time Pad).
| Variant | Difference from Vigenรจre |
|---|---|
| Beaufort |
C = (K โ P) mod 26. Encryption and decryption are the same operation. |
| Autokey | After the initial key, the plaintext itself extends the key, so there is no repeating period for Kasiski to find. |
| Running key | The key is a long passage from a book. It is still breakable, because both key and plaintext are natural language. |
| Gronsfeld | The key is digits (shifts 0โ9) instead of letters. |
If a Vigenรจre-style cipher uses a uniformly random, independent, secret key at least as long as the message, and the key is never reused, it becomes the One-Time Pad (OTP), which is provably unbreakable.
It achieves perfect secrecy (Shannon, 1949): the ciphertext contains no information about the plaintext. Every plaintext of the same length is compatible with some key. Observing the ciphertext does not change the prior probabilities of those plaintexts; it does not make all messages equally likely. Length can still be visible, and the pad does not authenticate messages.
The key distribution problem: The challenge is logistical. To encrypt a 1 GB file, you must first securely share a 1 GB truly random key. Pad material can be distributed securely in advance and used later when only an insecure communication channel is available. OTPs were therefore reserved for the highest-value links, such as the Cold War WashingtonโMoscow hotline, with key material physically carried by couriers.
Reuse is fatal: For a binary XOR pad, if two messages reuse the same pad, Cโ โ Cโ = Pโ โ Pโ; the key cancels out over the overlap. For the additive letter version, subtraction modulo 26 similarly cancels the pad. The U.S. VENONA project exploited exactly this against reused Soviet pads.
โ Alternative Alphabets ยท ๐ Classical Index ยท Building Your Own Alphabet โ
- deciphering-workbook.md - worked decryption, additional cipher families, and exercises
- cryptanalysis.md - how these ciphers are broken
- ../algorithms.md - modern replacements
โฌ ๏ธ Back to Master Index | ๐ฏ Role Navigation | Legal Notice
๐ Source: Cryptography/Classical/ciphers.md | โ๏ธ Suggest an edit | โฌ
๏ธ Back to Cryptography
- ๐บ๏ธ Browse by Topic
- ๐ All Repository Files
- ๐งญ Learning Paths
- ๐ Master Guide
- ๐ค Glossary
- โ๏ธ Legal & Disclaimer
๐ Foundations & Learning
๐ก๏ธ Defense & Investigations
- Incident Response
- Open Source Intelligence (OSINT)
- Reverse Engineering
- Operations Security (OPSEC)
- Compliance
โ๏ธ Platforms & Infrastructure
๐ก Hardware, Wireless & Field Projects
- PNWC Cyberdeck
- Hardware Testing
- Hardware Hacking
- Software-Defined Radio
- Wardriving
- uConsole
- Space Security
๐งฐ Assessment & Field Reference
๐ฆ Downloads & Project Resources
๐๏ธ Additional Topics