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

Using the Playfair tool

Type a key phrase in the Key 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 a young John F. Kennedy sent a Playfair message from the wreck of PT-109. Australian coastwatchers relayed it. By then the cipher had been breakable for 30 years, and the message went through because nobody nearby could read English, not because the cipher held.

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 the two rarest-clashing letters 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.