Playfair cipher
The
Playfair cipher is a manual
symmetric encryption technique invented in
1854 by
Charles Wheatstone for telegraph secrecy and was the first literal digraph substitution cipher. It was used by
British forces in the
Boer War and
World War I and also by the Australians during
World War II. It is named after Wheatstone's friend Lord
Lyon Playfair who popularized it. The technique encrypts pairs of letters (digraphs), instead of single letters as in the simple
Substitution cipher and rather more complex
Vigènere cipher systems then in use. The Playfair is thus significantly harder to break since straight
frequency analysis doesn't work with it.
It was not widely adopted by the British Foreign Office when it was developed. The reason is said to be that the Foreign Secretary rejected it because of its complexity. When told by Wheatstone and Playfair that schoolboys in a nearby school had learned to use it very quickly, he is sid to have responded, "That may be so, gentlemen, but our attaches could never learn it!"
The usual form of the cipher used a 5 by 5 table and a key word or phrase. Memorization of the key and 4 simple rules was all that was required to create the 5 by 5 table and use the cipher.
First fill in the spaces in the table with the letters of the key (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).
Then apply the following 4 rules, in order, to each pair of letters to encrypt a message:
- If the letters of a pair are both the same (or only one letter is left), add an "X" after the first letter. Encrypt the new pair and continue.
- 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.
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
^
The pair HI forms a rectangle, replace it with BM
The pair DE is in a column, replace it with ND
The pair TH forms a rectangle, replace it with ZB
The pair EG forms a rectangle, replace it with XD
The pair OL forms a rectangle, replace it with KY
The pair DI forms a rectangle, replace it with BE
The pair NT forms a rectangle, replace it with JV
The pair HE forms a rectangle, replace it with DM
The pair TR forms a rectangle, replace it with UI
The pair EX (X inserted to split EE) is in a row, replace it with XM
The pair ES forms a rectangle, replace it with MN
The pair TU is in a row, replace it with UV
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".
Like most pre-modern era cyphers, the Playfair cYpher can be easily cracked. Obtaining the key is trivial if both plaintext and ciphertext are known. When only the cyphertext is known, cryptanalysis of the cypher 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 language of the original message.
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
External Link