What it does
The Playfair cipher is a manual symmetric encryption technique invented in 1854 by Charles Wheatstone (and popularized by Lord Playfair). Unlike the Caesar cipher, which shifts one letter at a time, Playfair encrypts pairs of letters (digraphs), which makes basic frequency analysis much harder — a huge step up in security for a pen-and-paper cipher.
It works by arranging the alphabet (traditionally merging I and J into a single cell) into a 5×5 grid built from a keyword, then encrypting each letter pair according to the position of the two letters relative to each other in that grid.
Try it
How it works
- Build the key square — Write the keyword (duplicate letters and non-letters removed), followed by the remaining letters of the alphabet in order, into a 5×5 grid. I and J share the same cell.
- Prepare the plaintext — Remove all non-letter characters, convert
J→I, uppercase everything, then split it into pairs (digraphs). If both letters of a pair are the same, insert a filler letter (X, orQifXis already the pair's letter) between them. If the text has an odd number of letters after this, append a trailing filler. - Encrypt each pair according to where the two letters fall in the grid:
- Same row → replace each letter with the one immediately to its right (wrapping around to the start of the row).
- Same column → replace each letter with the one immediately below it (wrapping around to the top of the column).
- Rectangle (different row and column) → replace each letter with the one in its own row but in the column of the other letter, forming the opposite corners of the rectangle.
- Decrypt by reversing the rules: same-row shifts left, same-column shifts up, and rectangle swaps stay the same (since rectangle swapping is its own inverse).
Notes
- This tool merges I/J as is traditional. When decrypting,
Jnever reappears — onlyIdoes. - Filler letters inserted to break up double letters or pad an odd-length message will remain in the decrypted output; this is an inherent quirk of the classical cipher, not a bug.
- Only the 26 letters A–Z matter to the cipher; spaces, digits, and punctuation are stripped from the input before processing.
- The Playfair cipher was actually used for tactical (not high-level) military communications well into the 20th century, including by the British Army in the Second Boer War and by both sides in the early parts of World War I, precisely because it's fast to use by hand while resisting simple frequency analysis.
Example
With the keyword PLAYFAIR, the key square is:
| 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 |
Encrypting HELLO WORLD (after removing the space and splitting into HE LX LO WO RL D → padded to HE LX LO WO RL DX) produces the ciphertext shown live above when you type it into the widget.