06 — Classical
Playfair Cipher
Digraph substitution using a 5×5 key matrix. The first practical cipher to encrypt letter pairs, raising the alphabet from 26 symbols to 625.
Setup — build the 5×5 matrix
- Write the keyword, dropping duplicate letters
- Fill remaining cells with the rest of the alphabet in order. I and J share one cell (25 letters in a 25-cell grid)
M O N A R
C H Y B D
E F G I L
P Q S T U
V W X Z K
Matrix from keyword "MONARCHY" (I/J merged, K fills last cell).
Prepare plaintext
- Split into digraphs (pairs)
- If a pair has the same letter (e.g. LL), insert
Xbetween them → LX, L_ - If the final pair is incomplete, pad with
X
# Example: HELLO WORLD
HELLO → HE LX LO # LL split with X
WORLD → WO RL DX # final D padded with X
Encryption rules (3 cases)
① Same row
Replace each letter with the letter to its right (wrap around).② Same column
Replace each letter with the letter below it (wrap to top).③ Rectangle
Replace each letter with the letter in its own row but in the other letter's column.Decryption (mirror)
Same-row → shift left; same-column → shift up; rectangle → same as encryption (symmetric). Receiver uses the identical matrix.Worked examples (MONARCHY matrix)
# "HI" → rectangle: H(1,1), I(2,3)
H → row 1, col 3 = Y I → row 2, col 1 = C
HI → YC
# "AR" → same row 0: A(0,3), R(0,4) → shift right
A → R, R → M (wrap)
AR → RM
# "HE" → rectangle: H(1,1), E(2,0)
H → row 1, col 0 = C E → row 2, col 1 = F
HE → CF
Strength & weakness
- 625 digraphs vs 26 letters — needs ~25× more ciphertext for frequency analysis
- Still broken by digraph-frequency analysis on TH, HE, AN, IN, ER
- Used militarily in the Boer War and World War I
Exam one-liner: Right if same row, down if same column, else own-row/other-column. Decrypt = left/up.