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

  1. Write the keyword, dropping duplicate letters
  2. 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

# 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

Exam one-liner: Right if same row, down if same column, else own-row/other-column. Decrypt = left/up.
← Prev
05 · Vigenère Cipher
Next →
07 · AES