How to use the Playfair cipher tool
- Choose the Direction: Encrypt or Decrypt.
- Enter the Keyword. Spaces and repeated letters in it are ignored; the default is “playfair example”.
- Type into Your text. When decrypting, the ciphertext must have an even number of letters.
- Copy the Result. It comes out in capital letters without spaces, as Playfair messages traditionally do.
What it does and when to use it
The Playfair cipher was invented by Charles Wheatstone in 1854 and named after Lord Playfair, who promoted it. It was the first well-known cipher to encrypt letters in pairs, which hides single-letter frequencies better than a simple substitution. That makes it a popular step up in cryptography classes and a regular in puzzle hunts.
It is still a classical cipher meant for puzzles and teaching, not for protecting data; a computer breaks it quickly. If you like square-based ciphers, the four-square cipher also works on pairs but uses two keyword squares, and the bifid cipher splits letters into coordinates. The plain Polybius square shows the grid on its own.
How it works
The square. The keyword’s letters fill a 5×5 grid in order, repeats skipped, with J counted as I. The rest of the alphabet follows. With “playfair example”:
P L A Y F
I R E X M
B C D G H
K N O Q S
T U V W Z
The pairs. Only letters are kept, in capitals. The message is split into pairs. When the two letters of a pair would be the same, an X goes between them (Q if the letter is X), and an odd final letter gets an X.
The rules for each pair:
- Same row: each letter becomes the one to its right, wrapping round. Decryption goes left.
- Same column: each letter becomes the one below it, wrapping round. Decryption goes up.
- Rectangle: each letter is replaced by the letter in its own row but in the other letter’s column.
So HI, which forms a rectangle, becomes BM, and DE, in the same column, becomes OD. The tool does this in your browser.
Worked examples
Results from the tool:
Hide the gold in the tree stump key playfair example → BMODZBXDNABEKUDMUIXMMOUVIF
instruments key monarchy → GATLMZCLRQXA
GATLMZCLRQXA key monarchy, Decrypt → INSTRUMENTSX
ABC decrypt → Playfair ciphertext has an even number of letters.
The first line is the well-known example; its decryption reads HIDETHEGOLDINTHETREXESTUMP, with an X between the two Es of “tree”. The third line shows the pad X left at the end of INSTRUMENTS. When decrypting, the tool also adds a reminder that filler letters remain and that I and J share a cell.
Limits and tips
- Digits, spaces and punctuation are removed. Spell numbers out as words.
- A pair is never encrypted to itself, and reversed pairs (AB and BA) give reversed results. Code breakers use both facts.
Frequently asked questions
Why is there an extra X in my decrypted message?
What if the doubled letter is itself X?
Why does my result use I where I typed J?
Some textbooks show a different answer for the same message. Why?
How do we know nothing is uploaded? Test it yourself on the privacy proof page.