Playfair Cipher

The playfair cipher incorporates a polybius square to encipher pairs of letters rather than one letter at a time, making it significantly more difficult to solve than a letter-for-letter substitution cipher.  The examples show a 5x5 square, but a 6x6 square can be used in the same way.

The rules for enciphering in playfair are relatively simple:

First, the plaintext is divided into pairs (digraphs) of letters - any letter pair that would contain a doubled letter is separated by a null character and a null character is used if necessary to make the final digraph:

re po rt to th ex ed it or th is af te rn ox on

locate the letters of each digraph in the polybius square (Notes: j is generally represented as i in the ciphertext when a 5x5 square is used.  A keyword can be used to mix the alphabet.)  There are three possible ways the letters can relate to each other.  They can form opposite corners of a rectangle, they can be in the same row, or they can be in the same column. 

A B C D E
F G H I K
L M N O P
Q R S T U
V W X Y Z

corners of
a rectangle
      
A B C D E
F G H I K
L M N O P
Q R S T U
V W X Y Z

same row
      
A B C D E
F G H I K
L M N O P
Q R S T U
V W X Y Z

same column

If the digraph defines the corners of a rectangle, find the digraph that represents the other corners - in the illustrated example, using the letter that is in the same row as the first letter to replace the first letter and the letter in the same row as the second letter to replace the second letter, thus 're' is inciphered as 'UB.'

If the digraph contains two letters in the same row, each is replaced by the letter immediately to the right - if the letter is the rightmost in the grid, wrap around to the leftmost letter of the same row.  In the example, 'ed' is enciphered as 'AE.'

If the digraph contains two letters in the same column, each is replaced by the letter immediately below it in the grid.  If the letter is the bottom in its column, it is replaced by the top letter in the same column.  In our example, 'it' is enciphered as 'OY.'

Deciphering the message is the reverse process - using the next letter to the left in a row or the next letter up in a column and wrapping similarly.

Using our example message and the plain grid as shown,

re po rt to th ex ed it or th is af te rn ox on

enciphers to

UB LO SU YT SI CZ AE OY MT SI HT FL UD SM NY PO

regrouped into eights (though any period could be used)

UBLOSUYT SICZAEOY MTSIHTFL UDSMNYPO

Cryptanalysis involves frequency analysis of the 676 possible digraphs (though not all are found in english and may be safely ignored) and pattern recognition.  A very good description of analysis of a playfair cipher is presented in Dorothy Sayers' Lord Peter Wimsey story Have His Carcase.

 

further discussion of the playfair cipher can be found at Wikipedia