Playfair Cipher Converter
Encrypt or decrypt letter pairs with a keyed five by five square.
What it does
The Playfair cipher encrypts pairs of letters using a five by five square built from a keyword. It was invented by Charles Wheatstone and named after Lord Playfair, who promoted it in the nineteenth century.
This tool builds the key square by writing the keyword without repeated letters, then filling the remaining cells with the rest of the alphabet in order, combining I and J into one cell. It then applies the three geometric rules to each digraph.
The page opens with the message SHEWENTTOTHESTORE and keyword PROBLEMS. The doubled T in the middle is split with a Q, and the resulting ciphertext is AGMVMKUTQBYTMAQBPM.
For a pair in the same row, each letter moves one cell to the right with wrapping. For the same column, each moves one cell down. For a rectangle, each letter is replaced by the letter in its own row and the other letter's column.
The cipher was considered strong for its time because it hides single letter frequencies, but it is easily broken with modern methods.
How to use
- Type the message to encrypt or decrypt.
- Enter a keyword made of letters.
- Choose encrypt or decrypt.
- Read the converted message as the main result.
- Check the key square to follow the letter positions.
- Look at the digraphs to see where filler letters were inserted.
Formula
- key square
- The 5 by 5 grid built from the keyword.
- digraph
- A pair of letters encrypted together.
- filler
- A Q inserted to split doubled letters or complete an odd final pair.
Decryption reverses the row and column shifts and uses the same rectangle operation, which is its own inverse. Filler letters inserted during encryption must be removed by context after decryption.
Worked example
Example: SHEWENTTOTHESTORE with keyword PROBLEMS
The page opens with keyword PROBLEMS and the message SHEWENTTOTHESTORE.
- Build the square beginning PROBLEMS, then fill with A C D F G H I K N Q T U V W X Y Z.
- Split the message into pairs: SH EW EN TT OT HE ST OR E.
- The doubled TT becomes TQ, and the final single E becomes EQ.
- Apply the row, column and rectangle rules to each pair.
- The digraphs SH EW EN TQ TO TH ES TO RE produce AG MV MK UT QB YT MA QB PM.
- The tool reports the ciphertext AGMVMKUTQBYTMAQBPM.
Reference table
| Message | Keyword | Result |
|---|---|---|
| SHEWENTTOTHESTORE | PROBLEMS | AGMVMKUTQBYTMAQBPM |
Limits
- Messages are limited to 200 characters.
- Keyword must be 1 to 25 letters.
- I and J share one cell, so the cipher cannot distinguish them.
- Filler letters must be removed by context after decryption.
Common mistakes
- Using a keyword with repeated letters without removing them.
- Forgetting that J is treated as I.
- Encrypting doubled letters in the same pair directly.
- Shifting left instead of right during encryption.
- Expecting the filler Q to be removed automatically.
Try it yourself
Quick checks. Answers sit tucked under each question.
How many letters fit in the Playfair square?
25, with I and J sharing a cell.
What is done with a doubled letter pair?
A Q is inserted between them.
What happens for letters in different rows and columns?
Each is replaced by the letter in its row and the other letter's column.
Questions
Who invented the Playfair cipher?
Charles Wheatstone, with promotion by Lord Playfair.
Why encrypt pairs?
Pair encryption hides single letter frequencies better than simple substitution.
How is the square built?
Keyword first without repeats, then the remaining alphabet in order.
Why combine I and J?
A 5 by 5 grid has only 25 cells for 26 letters.
Is the rectangle rule reversible?
Yes, applying it again returns the original pair.
Is Playfair secure today?
No. It is a classical cipher broken by modern cryptanalysis.
Sources
- University of Central Florida, Playfair cipher lecture
- University of Valladolid, Playfair cipher problem specification
- American Cryptogram Association, Playfair cipher guide