# Playfair cipher

The Playfair system was invented by Charles Wheatstone, first described in 1854.

The Playfair cipher or Playfair square is a manual symmetric encryption technique and was the first literal digraph substitution cipher. The scheme was invented in 1854 by Charles Wheatstone, but bears the name of Lord Playfair who promoted the use of the cipher.

The technique encrypts pairs of letters (digraphs), instead of single letters as in the simple substitution cipher and rather more complex Vigenère cipher systems then in use. The Playfair is thus significantly harder to break since the frequency analysis used for simple substitution ciphers does not work with it. Frequency analysis can still be undertaken, but on the 676 possible digraphs rather than the 26 possible monographs. The frequency analysis of digraphs is possible, but considerably more difficult - and it generally requires a much larger ciphertext in order to be useful.

 Contents

## History

Lord Playfair promoted the use of the cipher, and his name became associated with the system.

The first recorded description of the Playfair cipher was in a document signed by Wheatstone on 26 March 1854. However, the scheme eventually came to be known by the name of Wheatstone's friend Lord Playfair, who popularized it. It was not adopted by the British Foreign Office when it was developed, rejected because of its perceived complexity. When Wheatstone offered to demonstrate that three out of four boys in a nearby school could learn to use it in 15 minutes, the Under Secretary of the Foreign Office responded, "That is very possible, but you could never teach it to attachés."

It was used by British forces in the Boer War and World War I and also by the Australians during World War II.

The first published solution of the Playfair was described in a 19-page pamphlet by Lieutenant Joseph O. Mauborgne, published in 1914.

## Using Playfair

The Playfair cipher uses a 5 by 5 table containing a key word or phrase. Memorization of the keyword and 4 simple rules was all that was required to create the 5 by 5 table and use the cipher.

To generate the key table, one would first fill in the spaces in the table with the letters of the keyword (dropping any duplicate letters), then fill the remaining spaces with the rest of the letters of the alphabet in order (usually omitting "Q" to reduce the alphabet to fit, other versions put both "I" and "J" in the same space). The key can be written in the top rows of the table, from left to right, or in some other pattern, such as a spiral beginning in the upper-left-hand corner and ending in the center. The keyword together with the conventions for filling in the 5 by 5 table constitute the cipher key.

To encrypt a message, one would apply the following 4 rules, in order, to each pair of letters in the plaintext:

• If both letters are the same (or only one letter is left), add an "X" after the first letter. Encrypt the new pair and continue. Some variants of Playfair use "Q" instead of "X", but any uncommon monograph will do.
• If the letters appear on the same row of your table, replace them with the letters to their immediate right respectively (wrapping around to the left side of the row if a letter in the original pair was on the right side of the row).
• If the letters appear on the same column of your table, replace them with the letters immediately below respectively (wrapping around to the top side of the column if a letter in the original pair was on the bottom side of the column).
• If the letters are not on the same row or column, replace them with the letters on the same row respectively but at the other pair of corners of the rectangle defined by the original pair. The order is important - the first encrypted letter of the pair is the one that lies on the same row as the first plaintext letter.

To decrypt, use the inverse of these 4 rules (dropping any extra "X"s that don't make sense in the final message when you finish).

## Example

Using "playfair example" as the key, the table becomes:

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

Encrypting the message "Hide the gold in the tree stump":

```HI DE TH EG OL DI NT HE TR EX ES TU MP
^
```
1. The pair HI forms a rectangle, replace it with BM
2. The pair DE is in a column, replace it with ND
3. The pair TH forms a rectangle, replace it with ZB
4. The pair EG forms a rectangle, replace it with XD
5. The pair OL forms a rectangle, replace it with KY
6. The pair DI forms a rectangle, replace it with BE
7. The pair NT forms a rectangle, replace it with JV
8. The pair HE forms a rectangle, replace it with DM
9. The pair TR forms a rectangle, replace it with UI
10. The pair EX (X inserted to split EE) is in a row, replace it with XM
11. The pair ES forms a rectangle, replace it with MN
12. The pair TU is in a row, replace it with UV
13. The pair MP forms a rectangle, replace it with IF
```BM ND ZB XD KY BE JV DM UI XM MN UV IF
```

Thus the message "Hide the gold in the tree stump" becomes "BMNDZBXDKYBEJVDMUIXMMNUVIF".

## Clarification with pictures

Assume one wants to encrypt the digraph OR. There are three general cases:

1)

```  * * * * *
* O Y R Z
* * * * *
* * * * *
* * * * *
```

Hence, OR -> YZ

2)

```  * * O * *
* * B * *
* * * * *
* * R * *
* * Y * *
```

Hence, OR -> BY

3)

```  Z * * O *
* * * * *
* * * * *
R * * X *
* * * * *
```

Hence, OR -> ZX

## Playfair cryptanalysis

Like most pre-modern era ciphers, the Playfair cipher can be easily cracked if there is enough text. Obtaining the key is relatively straightforward if both plaintext and ciphertext are known. When only the ciphertext is known, brute force cryptanalysis of the cipher involves searching through the key space for matches between the frequence of occurrence of digrams (pairs of letters) and the known frequency of occurrence of digrams in the assumed language of the original message.

Cryptanalysis of Playfair is similar to that of four-square and two-square ciphers, though the relative simplicity of the Playfair system makes identifying candidate plaintext strings easier. Most notably, a Playfair digraph and its reverse (e.g. AB and BA) will decrypt to the same letter pattern in the plaintext (e.g. RE and ER). In English, there are many words which contain these reversed digraphs such as REceivER and DEpartED. Identifying nearby reversed digraphs in the ciphertext and matching the pattern to a list of known plaintext words containing the pattern is an easy way to generate possible plaintext strings with which to begin constructing the key.

Another aspect of Playfair that separates it from four-square and two-square ciphers is the fact that it will never contain a double-letter digraph, e.g. EE. If there are no double letter digraphs in the ciphertext and the length of the message is long enough to make this statistically significant, it is very likely that the method of encryption is Playfair.

A good tutorial on reconstructing the key for a Playfair cipher can be found in chapter 7, "Solution to Polygraphic Substitution Systems," of Field Manual 34-40-2 (http://www.umich.edu/~umich/fm-34-40-2/), produced by the United States Army.

A detailed cryptanalysis of Playfair is undertaken in chapter 28 of Dorothy L. Sayers' mystery novel, "Have His Carcase." In this story, a Playfair message is demonstrated to be cryptographically weak as the detective is able to solve for the entire key making only a few guesses as to the formatting of the message (in this case, that the message starts with the name of a city and then a year). Sayers' book includes a detailed description of the mechanics of Playfair encryption as well as a step-by-step account of manual cryptanalysis. As a humorous side note, many online reviews for this book encourage readers to skip this chapter as it is too technical and involved.

 Classical cryptography edit  (https://search.academickids.com:443/encyclopedia/index.php?title=Template:Classical_cryptography&action=edit) Ciphers: ADFGVX | Affine | Atbash | Autokey | Bifid | Book | Caesar | Four-square | Hill | Permutation | Pigpen | Playfair | Polyalphabetic | Reihenschieber | Running key | Substitution | Transposition | Trifid | Two-square | Vigenère Cryptanalysis: Frequency analysis | Index of coincidence Misc: Cryptogram | Polybius square | Scytale | Straddling checkerboard | Tabula recta
de:Playfair

• Art and Cultures
• Countries of the World (http://www.academickids.com/encyclopedia/index.php/Countries)
• Space and Astronomy