StringMash.com

Playfair cipher

The first cipher to encrypt letters in pairs. Type a key phrase and the square rebuilds itself.

Conversion
21 characters
Updates as you type
Key: monarchy

Show the steps
  1. Build the square from the key MONARCHY: its letters first, then the rest of the alphabet, with I and J sharing a cell.
  2. M O N A R
  3. C H Y B D
  4. E F G I K
  5. L P Q S T
  6. U V W X Z
  7. Split the message into pairs: ME ET ME AT TH EB RI DG EX
  8. The last letter is on its own, so X is added to make a pair.
  9. ME: same column, so each moves one down: CL
  10. ET: a rectangle, so each takes the corner on its own row: KL
  11. ME: same column, so each moves one down: CL
  12. AT: a rectangle, so each takes the corner on its own row: RS
  13. TH: a rectangle, so each takes the corner on its own row: PD
  14. EB: a rectangle, so each takes the corner on its own row: IC
  15. RI: a rectangle, so each takes the corner on its own row: AK
  16. DG: a rectangle, so each takes the corner on its own row: YK
  17. The other 1 pair follow the same rule.

Using the Playfair tool

Type a key phrase in the Key phrase box and the 5x5 square rebuilds as you type. The text on the left is enciphered two letters at a time, and the arrows turn it back.

Splitting letter decides what gets pushed between a doubled pair, because the cipher has no rule for LL or EE. X is the usual choice. Pick Q or Z if your message is full of Xs.

How the pairs work

The key phrase fills a 5x5 grid first, letter by letter, skipping any it has already used. The rest of the alphabet follows. That leaves 25 cells for 26 letters, so I and J share one.

Now take the text two letters at a time. If both sit on the same row, each moves one place right. Same column, each moves one place down. Otherwise they form the corners of a rectangle, and each letter swaps to the corner in its own row.

Enciphering pairs rather than single letters is what made it hard for its time. A frequency count of single letters tells you almost nothing, because E is not always E. You'd need to count all 600 possible pairs, and a short message never gives you enough of them.

Wheatstone invented it, Playfair got the name

Charles Wheatstone devised it in 1854. His friend Lyon Playfair, later Lord Playfair, took it to the Foreign Office and promoted it hard enough that the name stuck to him instead.

Whitehall turned it down as too complicated for the field. Wheatstone offered to teach it to four boys from a nearby school and said three of them would have it inside 15 minutes. The offer didn't move anyone, and the cipher went into service anyway, first in the Boer War and then in the trenches of the First World War.

It was still in use in 1943. When PT-109, John F. Kennedy's torpedo boat, was sunk in Blackett Strait, the Australian coastwatcher Reginald Evans learned of it from a Playfair message and coordinated the rescue by encrypted radio. By then a published method for breaking the cipher was 29 years old.

Related conversions

The Caesar cipher moves one letter at a time, and that single-letter habit is exactly the weakness Playfair was built to fix. The Polybius square uses the same 5x5 grid but reads coordinates out of it rather than swapping corners.

If you're holding text and don't know what made it, start at the cipher identifier.

Questions

What is the Playfair cipher?

A manual cipher from 1854 that encrypts two letters at a time using a 5x5 square built from a key phrase. It was the first practical digraph cipher.

Why do I and J share a square?

Because 26 letters don't fit in 25 cells. Merging two letters that rarely clash was the cheapest fix, and readers can tell from context which one was meant.

Why does an X appear in my text?

The cipher can't encipher a doubled pair like LL, so a splitting letter goes between them. An odd final letter gets one too, which is why decoded text often ends in X.

Is the Playfair cipher secure?

No. Lieutenant Joseph Mauborgne published a method for breaking it in 1914, and a few hundred letters of ciphertext are enough. Treat it as a puzzle.

Sources

Added . Last updated and reviewed . What's new