Reference
The Playfair Cipher Explained
The Playfair cipher encrypts pairs of letters, called digraphs, using a 5x5 grid built from a keyword, rather than encrypting one letter at a time. That single change made it far harder to break by frequency analysis than any single-letter substitution cipher that came before it.
Last updated 14 July 2026
Building the key square
Write your keyword into a 5x5 grid, skipping any letter that repeats, then fill the remaining cells with the rest of the alphabet in order. Since 26 letters cannot fit 25 cells, I and J share a single cell.
The finished grid becomes the key both people need to share. A different keyword produces a completely different grid, and therefore a completely different set of encrypted pairs for the same message.
Encrypting a pair of letters
Split the message into pairs of letters. If a pair would repeat the same letter twice, or one letter is left over at the end, a filler letter (usually X) is inserted so every pair has two distinct letters.
Each pair is then transformed using one of three rules: same row shifts each letter right, same column shifts each letter down, and any other pair swaps to the opposite corners of the rectangle the two letters form in the grid.
Frequently asked questions
Why is the Playfair cipher stronger than a simple substitution?
It encrypts pairs of letters instead of single letters, which spreads out the letter-frequency patterns that make ciphers like Caesar and Atbash easy to break by counting how often each letter appears.
Who used the Playfair cipher?
The British Army used it as a field cipher from the Second Boer War through both World Wars, since it could be encrypted and decrypted by hand quickly enough for battlefield use.