Playfair Cipher Encoder and Decoder
Encrypt and decrypt with the Playfair cipher. Enter a keyword, see the 5×5 key square and get the result in letter pairs. Free, runs in your browser.
How it works
The Playfair cipher encrypts pairs of letters with a 5×5 square of 25 letters. To build the square, write the letters of the keyword without repeats, then the rest of the alphabet; I and J share one cell. Prepare the message: keep only letters, turn J into I and split it into pairs. If a pair has the same letter twice, an X is put between them, and an odd last letter gets an X added. Each pair is then encrypted by one of three rules. Same row: take the letter to the right of each, wrapping to the start of the row. Same column: take the letter below each, wrapping to the top. Otherwise the two letters form the corners of a rectangle: take the letter in the same row but in the other letter's column. Decryption uses the same square and moves left and up instead. The filler X letters stay in the decrypted text, so remove them by reading.
Example from the classic description: with the keyword playfair example, Hide the gold in the tree stump becomes BM OD ZB XD NA BE KU DM UI XM MO UV IF.
Key square for the keyword PLAYFAIR EXAMPLE
| 1 | 2 | 3 | 4 | 5 |
|---|---|---|---|---|
| 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 |
Encrypting pair by pair
| Pair | Encrypted |
|---|---|
| HI | BM |
| DE | OD |
| TH | ZB |
| EG | XD |
| OL | NA |
| DI | BE |
| NT | KU |
| HE | DM |
| TR | UI |
| EX | XM |
| ES | MO |
| TU | UV |
| MP | IF |
Frequently asked questions
How do I decrypt a Playfair cipher?
Choose Decrypt, enter the keyword that was used to encrypt and paste the ciphertext. The result shows the plain text in pairs, including any filler X letters.
Why is there an X in my decrypted text?
Playfair cannot encrypt a pair of two identical letters, so an X is inserted between them, and an X is added when the message has an odd number of letters. Read past these fillers.
Why does J become I?
The key square has 25 cells for 26 letters, so I and J share a cell. Decrypted text shows I in both places.
Who invented the Playfair cipher?
Charles Wheatstone invented it in 1854. It is named after Lord Playfair, who promoted its use. British forces used it in the Boer War and the First World War.
Is Playfair secure?
No. It hides single letter frequencies better than the Caesar cipher, but pair frequencies give it away, and it can be broken by hand with enough text.
Is my text sent to a server?
No. Everything runs in your browser and the text you type is not sent anywhere.
More text tools
Cipher Decoder and Identifier
Morse Code Translator
Binary Translator
ASCII Converter
Hex to Text Converter
Leet Speak Translator
Caesar Cipher Encoder and Decoder
Vigenere Cipher Encoder and Decoder
Atbash Cipher Encoder and Decoder
Word Counter and Character Counter
ROT13 Decoder and Encoder
Rail Fence Cipher Encoder and Decoder
Braille Translator
Pigpen Cipher Translator
Letter to Number Converter (A1Z26)
Bacon Cipher Encoder and Decoder
Tap Code Translator
Polybius Square Cipher
Playfair is a historical cipher for puzzles and learning, not for real secrets.