The Playfair Cipher is a simple transposition cipher offering a relatively weak method of encryption. It was used by many countries during wartime and extensively by Britain in World War 1, and Germany during World War 2. It is based around a 5x5 matrix, a copy of which is held by both communicating parties, into which 25 of the 26 letters of the alphabet (normally either j and i are represented by the same letter or x is ignored) are placed in a random fashion i.e.

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

The plaintext message is then created, stripped of any spaces or punctuation, any required substitutions take place (i.e. I for J, eliminating X etc.) and it is then grouped into pairs of letters. These letter pairs then undergo the following encryption techniques

1) If a double letter occurs insert a 'dummy' letter between them
2) If a letter pair are at the corners of a rectangle,substitute the letters at the opposing corners (eg TO -> AI)
3) If a letter pair are in the same row, substitute the letters one to the right (eg MA -> UM)
4) If the letter pair are in the same column, substitute the letters one below (eg EC -> PT)

To decrypt a message divide the ciphertext into letter pairs and follow the following decryption techniques

1) If the letter pair are in the same column then substitute the letters one position above
2) If the letter pair are in the same row then substitute the letters one position to the left.
If there are any dummy letters it should now become obvious

The main weakness in this method is the fixed encryption/decryption table.

The playfair cipher was created by Sir Charles Wheatstone (known for the Wheatstone bridge). Wheatstone and Baron Playfair of St. Andrew's both had cryptography as a serious hobby.

The London Times frequently carried private advertisements done in code and the two men amused themselves by breaking the code and following the correspondence. One particular correspondence was between a student at Oxford and a married lady in London. At one point, the young man suggested that they should elope. Wheatstone ran a coded message of his own in the cipher used by the couple in which he admonished the lady. One message followed using that cipher - "Charles, don't write anymore; our cipher has been broken!"

Wheatstone at that time had a superior cipher system which he had invented. His friend Baron Playfair published it giving proper credit to Wheatstone for its invention. Nevertheless, it is known as the Playfair cipher.

Frequently a mixed alphabet is used with a mnemonic - taking a shared word and then removing all the letters that occur twice. For the following example the word 'ceaser' (yes, I know its misspelled - I didn't catch the spelling error until after I did the encryption. It is still a 'good' key) will be used. After that word has been written down, the remaining letters of the alphabet follow. This is all written down in a 5x5 box. Changes are necessary to make an alphabet fit this grid. The most common changes are (only one change is necessary):

  • 'i' -> 'j'
  • 'j' -> 'ii'
  • 'W' -> 'VV'
  • 'U' -> 'V'
  • no 'X'

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

Next, the plaintext is written out with no punctuation in a straight stream. The letters are then divided into pairs. A solitary letter has an arbitrary letter appended to it. Doubled letters have a obvious character (called a 'null') placed between them.

original: hello there bob
paired stream: he ll ot he re bo b modified stream: he lx lo th er eb ob ciphered stream: rd qa qi gu ac dc vi

There are three possibilities:

  1. Both letters are in the same row
    The characters 'ER' appear in the same row in the above block, and thus they are shifted one set to the right, wrapping around as necessary. 'ER' becomes 'AC'.
  2. Both letters are in the same column
    The characters 'OB' appear in same column, thus to encipher these, the characters one position below are used. 'OB' becomes 'VI'.
  3. The letters are neither in the same row or column
    When the letters are not in the same row or column, a rectangle is formed with them, and the opposite corners are chosen, with the swap happening between letters in the same column. 'HE' become 'RD' and 'EB' becomes 'DC'.

It is easy to remember this system, and thus quite useful on the go. Furthermore, it is easy to change the key and thus the table. It can be cracked with enough texts. Instead of individual letter frequency, it now requires the analysis of letter pair frequency - much more difficult. A further enhancement upon this is to use a serration so that the plaintext of 'hello there bob' becomes:

plain text: helloth
            erebxob

ciphered:   raafvub
            dckiqpd
Here, the vertical pairs are used rather than horizontal making common pairings such as 'TH' more difficult to find.


In World War II, the Playfair cypher was modified to be applied again making the unauthorized decoder's life a bit more difficult. This was called 'Doppelkasten' (double box) by the Germans.

Two different boxes are used with different texts as keys. For the left box in this example, the key used will be the 'ceaser' key as above. For the right box, the key 'the quick brown fox jumped over the lazy dogs' (this happens to have each letter at least once).

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

For encoding, the plain text is arranged in an even number of equal lines. Extra characters (nulls) are added as necessary to the end. The message "Everything is great, we love it all" would become:

EVER YTHI
NGIS GREA

TWEL OVEI
TALL WXYZ
The pair of letters 'EN' is then encoded. Draw a line between 'E' on the left hand box to the 'N' on the right hand box. This is then mirrored to become 'K' from the left hand side and 'E' from the right hand side. This pair is then encoded a second time: 'KE' becomes 'NE'. This flipping is an artifact of the fact that 'E' and 'K' are in the same column in both tables.

What happens if both are on the same row as 'VG' are? This invokes an exception. This often happens if both of the keys are of the same length and the letter pair is in the last row (frequently the same or similar) The pair is mirrored and then displaced by one letter to the left. If this causes it to wrap, it stays in the same box. 'VG' then becomes 'ZY'. The repetition of this shifts it again to 'YA'

'EI' becomes 'TD' which then becomes 'QP' (invoking the above rule). 'RS' becomes 'UZ' which in turns becomes 'PU'.

And thus, our cypher text begins:

NYQP ....
EAPU ....

.... ....
.... ....

During World War II, the boxes where changed every 3 hours, however there was enough traffic to provide cryptanalysts enough text to decode these. At the end of the war, the double encryption was relaxed to single encryption.


The box of the playfair cypher can be extended to a 3x9 (A-Z, &) or a 6x6 (A-Z and 0-9)

Log in or register to write something here or to contact authors.