Katana VentraIP

Playfair cipher

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

Not to be confused with Wadsworth's cipher.

The technique encrypts pairs of letters (bigrams or digrams), instead of single letters as in the simple substitution cipher and rather more complex Vigenère cipher systems then in use. The Playfair cipher is thus significantly harder to break since the frequency analysis used for simple substitution ciphers does not work with it. The frequency analysis of bigrams is possible, but considerably more difficult. With 600[1] possible bigrams rather than the 26 possible monograms (single symbols, usually letters in this context), a considerably larger cipher text is required in order to be useful.

Superseded[edit]

Playfair is no longer used by military forces because of known insecurities and of the advent of automated encryption devices. This cipher is regarded as insecure since before World War I.


The first published solution of the Playfair cipher was described in a 19-page pamphlet by Lieutenant Joseph O. Mauborgne, published in 1914.[11] William Friedman described it in 1942 as providing very little security.[12]

Cryptanalysis[edit]

Like most classical 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 frequency of occurrence of digrams (pairs of letters) and the known frequency of occurrence of digrams in the assumed language of the original message.[14]


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.


A different approach to tackling a Playfair cipher is the shotgun hill climbing method. This starts with a random square of letters. Then minor changes are introduced (i.e. switching letters, rows, or reflecting the entire square) to see if the candidate plaintext is more like standard plaintext than before the change (perhaps by comparing the digrams to a known frequency chart). If the new square is deemed to be an improvement, then it is adopted and then further mutated to find an even better candidate. Eventually, the plaintext or something very close is found to achieve a maximal score by whatever grading method is chosen. This is obviously beyond the range of typical human patience, but computers can adopt this algorithm to crack Playfair ciphers with a relatively small amount of text.


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 digram, e.g. EE. If there are no double letter digrams 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, produced by the United States Army. Another cryptanalysis of a Playfair cipher can be found in Chapter XXI of Helen Fouché Gaines' Cryptanalysis / a study of ciphers and their solutions.[15]


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 date). Sayers' book includes a detailed description of the mechanics of Playfair encryption, as well as a step-by-step account of manual cryptanalysis.


The German Army, Air Force and Police used the Double Playfair cipher as a medium-grade cipher in WWII, based on the British Playfair cipher they had broken early in WWI.[16] They adapted it by introducing a second square from which the second letter of each bigram was selected, and dispensed with the keyword, placing the letters in random order. But with the German fondness for pro forma messages, they were broken at Bletchley Park. Messages were preceded by a sequential number, and numbers were spelled out. As the German numbers 1 (eins) to twelve (zwölf) contain all but eight of the letters in the Double Playfair squares, pro forma traffic was relatively easy to break (Smith, page 74-75)

Use in modern crosswords[edit]

Advanced thematic cryptic crosswords like The Listener Crossword (published in the Saturday edition of the British newspaper The Times) occasionally incorporate Playfair ciphers.[17] Normally between four and six answers have to be entered into the grid in code, and the Playfair keyphrase is thematically significant to the final solution.


The cipher lends itself well to crossword puzzles, because the plaintext is found by solving one set of clues, while the ciphertext is found by solving others. Solvers can then construct the key table by pairing the digrams (it is sometimes possible to guess the keyword, but never necessary).


Use of the Playfair cipher is generally explained as part of the preamble to the crossword. This levels the playing field for those solvers who have not come across the cipher previously. But the way the cipher is used is always the same. The 25-letter alphabet used always contains Q and has I and J coinciding. The key table is always filled row by row.

The novel by Dorothy L. Sayers gives a blow-by-blow account of the cracking of a Playfair cipher.

Have His Carcase

The World War 2 thriller The Trojan Horse by conceals the formula for a new high-strength metal alloy using the Playfair cipher.

Hammond Innes

In the film , a treasure hunt clue is encoded as a Playfair cipher.

National Treasure: Book of Secrets

In the audio book : God of Thunder, a Playfair cipher clue is used to send Anja Creed to Venice.

Rogue Angel

In the novel York: The Map of Stars (part three of a trilogy for children) by , a clue to solving the Morningstarr cipher is encrypted using the Playfair cipher.

Laura Ruby

The Playfair cipher serves as a plot device in a season 2 episode of the 2019 .

Batwoman (TV series)

In the novel , a Playfair cipher is discovered in the footnotes of the story.

S. (Dorst novel)

Topics in cryptography

Gaines, Helen Fouché (1956) [1939], , Dover, ISBN 0-486-20097-3

Cryptanalysis / a study of ciphers and their solutions

Smith, Michael Station X: The Codebreakers of Bletchley Park (1998, Channel 4 Books/Macmillan, London)  0-7522-2189-2

ISBN

Kahn, David (1996), The Codebreakers: The Comprehensive History of Secret Communication from Ancient Times to the Internet, Scribner,  978-0684831305

ISBN

Online encrypting and decrypting Playfair with JavaScript

Extract from some lecture notes on ciphers – Digraphic Ciphers: Playfair

Playfair Cipher

Cross platform implementation of Playfair cipher

Javascript implementation of the Playfair cipher

Python and streamlit implementation of Playfair cipher