How to use it
Type a keyword. The 5×5 key square updates as you type: the keyword’s letters come first, each only once, followed by the rest of the alphabet in order. Then type or paste a text into the left box and the right box shows the result at once. Choose Encrypt or Decrypt at the top; both directions need the same keyword and settings. To check the round trip, press “Use the result as input”.
Playfair works on letter pairs, so the text is prepared first; the panel below the boxes shows each stage. Spaces, digits and punctuation are dropped (write numbers as words), letters with diacritics such as é or ü become plain letters, and everything is written in capitals. J becomes I, because I and J share one cell; with “Omit Q” every Q is removed instead. The letters are then split into pairs. When both letters of a pair would be the same, as in the EE of TREE, a filler letter goes between them, and a single letter left at the end gets the filler too. If the doubled letter is the filler itself, the next letter of the list X, Q, Z is used instead, skipping Q when the square has no Q.
Controls
- Keyword, Alphabet, Filler letter and Output change the result instantly. The output comes in pairs, in groups of five or without spaces.
- Step-through: Prev and Next pair, or the slider, walk through the pairs of the current text. The square marks the two input letters (numbered 1 and 2), the rule and the two output letters. “Reverse this pair” shows the same pair with its letters swapped.
- Copy copies either box. The samples include doubled letters, a J, a Q, digits and an accented letter.
- Keyboard: Tab moves between the controls, Space or Enter presses a button and the arrow keys move the slider.
How it works
Number the rows and columns of the square from 0 to 4. A pair of two different letters at (r1, c1) and (r2, c2) is encrypted by one of three rules, where rows and columns wrap around:
same column: (r, c) → (r + 1 mod 5, c)
rectangle: (r1, c1), (r2, c2) → (r1, c2), (r2, c1)
Decryption uses the inverse rules: the letter to the left, the letter above, and the rectangle rule again, which undoes itself. The fillers come back in the decrypted text. A reader removes them by sense, so the page marks the likely ones under the result: a filler between two equal letters, or at the very end.
With the keyword PLAYFAIR EXAMPLE, I and J merged and filler X, “Hide the gold in the tree stump” becomes BMODZBXDNABEKUDMUIXMMOUVIF. Charles Wheatstone invented the cipher in 1854. It is named after Lord Playfair, who promoted its use.
The four cards above the article measure the weaknesses on your own text. Each plaintext pair always becomes the same ciphertext pair, so pair frequencies survive; with enough text, the most common ciphertext pairs point to common English pairs such as TH, HE, IN and ER. If AB becomes XY, then BA becomes YX, because all three rules treat the two letters the same way, so words like ER and RE leave matching reversed pairs. Finally, a ciphertext pair never has a doubled letter and no letter ever encrypts to itself, because every rule moves a letter to another row or column. In random letters, about one pair in 25 would be doubled and about one letter in 25 would match.
Things to try
- Load the classic example and step to pair 10: the filler X turned the EE of TREE into EX. Then change the keyword one letter at a time and watch which cells of the square move.
- Load the harbour log and switch the alphabet to Omit Q: the Q of “quiet” and “quay” disappears in the preparation steps.
- Encrypt the mountain notes and compare the frequency bars: every ciphertext bar has exactly the height of its plaintext bar.
- Turn on “Reverse this pair” and step through: the output pair is always reversed too.
- Decrypt a made-up ciphertext that contains a pair such as AA. The page warns that Playfair never produces one.
Frequently asked questions
Why do I and J share one cell?
A 5×5 square has 25 cells for 26 letters, so one letter has to go. J is rare in English and still reads well as I, so merging I and J is the usual choice. Leaving out Q is the other common option.
Why is there an extra X in my decrypted text?
It is a filler or padding letter added before encryption. The cipher cannot tell a filler from a real X, so a person drops it while reading. The reading aid under the result marks the likely ones.
Can Playfair encrypt digits?
No. The square holds letters only, so digits, spaces and punctuation are dropped. Write numbers as words, for example SEVEN.
Is the Playfair cipher secure today?
No. Working on pairs hides single-letter frequencies better than a simple substitution, but pair frequencies and the reversed pairs remain. It can be broken by hand with enough ciphertext, and computer programs that try and improve key squares break it quickly.
Sources
- Reid W (1899). Memoirs and correspondence of Lyon Playfair, pages 158–159. Cassell. Playfair’s own account of showing Wheatstone’s new cipher, with its key word and rectangle rule, to cabinet ministers in January 1854.