1. Home
  2. Writing & text tools
  3. Playfair Cipher

Playfair Cipher

Learn and use the cipher of Victorian diplomats and WWI field units: letters are encrypted in pairs using a square built from a keyword.

Free, no sign-up. Runs in your browser: nothing is uploaded.

How to use Playfair Cipher

  1. Type the keyword.
  2. Choose encrypt or decrypt and type the text.
  3. Read the result and the key square.

Features

  • Key square from any keyword or phrase
  • I/J merged or Q left out
  • Choice of filler letter, with an alternative for doubled fillers
  • Prepared pairs shown for checking by hand
  • This is a classical cipher for puzzles, games and teaching. It does not protect real secrets.

Supported formats

You can open

  • Typed or pasted text
  • TXT

You get

  • Copied text
  • TXT

Private by design

Your files are opened and processed by your browser on this device. They are never uploaded to openWorkstand or anyone else, so the Playfair Cipher is safe for contracts, IDs, photos and work documents. After you have used it once while online, it also works without an internet connection. How local processing works

Good to know

  • A classical cipher for puzzles and teaching: it can be broken quickly and must not be used to protect real secrets.

Guide

The Playfair cipher: encrypting letter pairs with a 5×5 square

The Playfair cipher was the first practical cipher to encrypt pairs of letters instead of single letters. That hides the simple letter frequencies that break substitution ciphers like Caesar and Atbash, which made it a useful field cipher for over half a century. This tool builds the key square, prepares the pairs and applies the rules, showing every step so you can follow along or check work done by hand.

Building the key square

Write the keyword’s letters into a 5×5 grid, row by row, skipping any letter already used, then fill the remaining cells with the rest of the alphabet in order. A 5×5 grid has 25 cells, so one letter must go: by default J is written as I and shares its cell; alternatively Q, the rarest English letter, is left out. With the keyword PLAYFAIR EXAMPLE, the square begins P L A Y F / I R E X M.

Preparing the message

The message is written in capitals without spaces and split into pairs. A pair may not contain the same letter twice, so a filler — normally X — is inserted between doubled letters: “tree” becomes TR EX E… If the message ends with a single letter, a filler is added. When the filler would itself be doubled, the alternative filler is used instead. The prepared pairs are shown under the square.

The three rules

For each pair, find both letters in the square. If they are in the same row, replace each with the letter to its right, wrapping around to the start of the row. If they are in the same column, replace each with the letter below, wrapping to the top. Otherwise they form the corners of a rectangle: replace each with the letter in its own row at the other letter’s column. The well-known example “Hide the gold in the tree stump” with this key encrypts to BMODZBXDNABEKUDMUIXMMOUVIF.

Decrypting

Decryption applies the rules in reverse: left instead of right, up instead of down; the rectangle rule is unchanged. The result still contains the fillers and has I in place of J, because that information was removed when the message was prepared. Remove stray Xs while reading.

Strengths and weaknesses

Encrypting pairs gives 600 possible digraphs instead of 26 letters, which defeats simple frequency counting. But common pairs such as TH, HE and IN still show through, a letter never encrypts to itself, and a reversed pair encrypts to the reversed result. With enough text, Playfair is broken by hand; computers do it in seconds. It is ideal for teaching and puzzles.

Private

Everything runs in your browser.

A worked example

With the key square for PLAYFAIR EXAMPLE, the pair HI is a rectangle case: H is in row 3, column 5 and I in row 2, column 1. Each letter is replaced by the letter in its own row at the other’s column, giving B and M, so HI becomes BM. The pair DE has D and E in the same column, so each moves down one row: D becomes O and E becomes D, giving OD. These are the first two pairs of the classic example, BM OD ZB.

Try a keyword cipher with the Vigenère Cipher, coordinates in a square with the Tap Code Translator, transposition with the Rail Fence Cipher, or start simple with the Caesar Cipher Solver.

Checked against the current version of the Playfair Cipher on .

Troubleshooting

The file does not open

Check that it is one of the supported formats above and opens in another app. Damaged files and password-protected PDFs cannot be read until they are repaired or unlocked.

It is slow or stops on a very large file

Everything runs on your device, so speed depends on its memory. Close other tabs, use a computer rather than a phone, or split the file into smaller parts first.

The download did not start

Look for your browser’s download bar or icon. Some browsers ask once before a site may download files; allow it and click the button again.

Frequently asked questions

Why is the cipher text always an even number of letters?

Playfair encrypts letters two at a time. If the prepared message has an odd number of letters, a filler is added at the end, so the cipher text always splits into whole pairs.

Can a letter be encrypted as itself?

No. Every rule moves each letter to another cell of the square, so a letter never stands for itself. That is one of the clues cryptanalysts use to break Playfair.

Who invented the Playfair cipher?

Charles Wheatstone invented it in 1854, but it carries the name of Lord Lyon Playfair, who promoted it to the British government. It was used by British forces in the Boer War and the First World War.

Why does the decrypted text contain extra X letters?

Playfair cannot encrypt a pair of identical letters, so a filler is inserted between them and after an odd final letter. The fillers remain after decryption; remove them while reading.

What happens to the letter J?

The square has 25 cells, so one letter must share or go. Usually J is written as I; the alternative leaves out Q, which is rare in English.

Keep working with the result

After you download, choose “Save to Workstand” to keep the result in a folder on your computer, attach it to a project and create a follow-up task. It is saved by your browser, not uploaded.