Skip to content
ZeroServer.tools

Playfair Cipher

Encrypt and decrypt text with the 5×5 Playfair digraph substitution cipher.

Key square (I = J):
P
L
A
Y
F
I
R
B
C
D
E
G
H
K
M
N
O
Q
S
T
U
V
W
X
Z
Ciphertext
EBIMQMGHVRCZ

How the Playfair cipher works

The Playfair cipher encrypts pairs of letters (digraphs) using a 5×5 key square built from a keyword. I and J share a cell. Pairs in the same row shift right; same column shifts down; otherwise each letter moves to the opposite corner of the rectangle they form. It was used by the British and Australians in World War I and World War II.

Built and maintained by Meet Shah · Last updated

What this tool is used for

  • Working through a classical cryptography exercise where digraph substitution is the mechanism being taught.
  • Solving a puzzle or CTF challenge whose ciphertext has an even length and no repeated adjacent letters.
  • Demonstrating why enciphering letter pairs resists simple frequency analysis better than single letters do.
  • Reproducing a historical message to check a published key square against it.
  • Building a teaching example that shows how a key phrase becomes a five-by-five grid.

Frequently Asked Questions

Why do I and J share a square?
Because the alphabet has 26 letters and the grid holds 25. Merging I and J is the standard choice — they were the least disruptive pair in English — so decrypting gives IUNE for JUNE and the reader restores it from context. Some variants drop Q instead.
What are the three encryption rules?
Take letters in pairs. Same row: replace each with the letter to its right, wrapping. Same column: replace each with the letter below, wrapping. Otherwise: form a rectangle and swap each letter for the one in its own row at the other corner.
Why does an X appear in my text?
Padding. A pair of identical letters cannot be enciphered, so an X is inserted between them — BALLOON becomes BA LX LO ON — and a final odd letter gets an X too. Decryption leaves those X's in place, because removing them automatically would corrupt any word that really contains one.
How strong is it?
Broken since 1914, and unusable for anything real. Enciphering pairs rather than single letters defeats simple letter-frequency analysis, but digraph frequencies leak just as clearly, and a few hundred characters of ciphertext are enough to recover the key.
What was it actually used for?
Field cipher work. Invented by Charles Wheatstone in 1854 and championed by Lord Playfair, it was used by the British in the Boer War and the First World War, and by Australian coastwatchers in the Second — chosen because it needs no equipment beyond a grid you can memorise.

Common errors and gotchas

  • Forgetting that I and J share one square, so the decrypted text needs a human to decide which letter was meant.
  • Being surprised by inserted padding letters. Repeated letters in a pair must be separated, and an X is the usual filler.
  • Using a key phrase with repeated letters and building the square from all of them rather than first occurrences only.
  • Expecting punctuation and digits to survive. The square holds twenty-five letters and nothing else at all.
  • Treating it as secure. It falls to digraph frequency analysis given a moderate amount of ciphertext.

Related Encoders & Decoders tools

Private & free — this tool runs entirely in your browser.

IndieKitShip your Next.js startup in days.affiliate