# Playfair cipher decoder and encoder

The Playfair cipher was invented in 1854 by Charles Wheatstone, but named after lord Playfair who heavily promoted the use of the cipher. It is a polygraphic substitution cipher, which encrypts pair of letters instead of single letters. This makes frequency analysis much more difficult, since there are around 600 combinations instead of 26.

## Playfair cipher

Translate this letter into

## Features

• The Playfair cipher is a classic form of polygraphic substitution cipher. It was the first practical polygraph substitution cipher in use.
• It was invented in 1854 by Charles Wheatstone, but named after lord Playfair after he promoted it heavily.
• Instead of encrypting single letters, the Playfair cipher encrypts pairs of letter (digrams or bigrams). This makes frequency analysis much harder, since there are around 600 combinations instead of 26.
• A grid of 5x5 letters is used for encryption. Since there are only 25 spots, one character has to be omitted (for instance J, which is replaced by I).
• The grid is formed by first taking a code word (with duplicate letters removed) and then adding any alphabet characters missing.
• A digraph is transformed by looking up the two characters in the grid. If they form a rectangle, pick letters from the same rows but other corners. If they form a column, pick the letters one row down. If they form a row, pick the letters one step to the right. If they are same letter, add a padding letter (for instance X) or pick the letters on row down and one step to the right. See here for a more comprehensive description.
• The Playfair cipher was used during World War I, but is no longer used by military forces since it can easily be broken by modern computers.

Playfair ciphers, and variants of it, are occasionally used in CTFs, geocaching mystery caches, and logic puzzles.

## Sample text

NCBDQBGRKNAQHPNTNQUN

The ciphertext above represents "SIR CHARLES WHEATSTONE" encrypted using the key PLAYFAIR.