Playfair cipher
   HOME

TheInfoList



OR:

The Playfair cipher or Playfair square or Wheatstone–Playfair cipher is a manual
symmetric Symmetry (from grc, συμμετρία "agreement in dimensions, due proportion, arrangement") in everyday language refers to a sense of harmonious and beautiful proportion and balance. In mathematics, "symmetry" has a more precise definiti ...
encryption In cryptography, encryption is the process of encoding information. This process converts the original representation of the information, known as plaintext, into an alternative form known as ciphertext. Ideally, only authorized parties can d ...
technique and was the first literal digram substitution cipher. The scheme was invented in 1854 by
Charles Wheatstone Sir Charles Wheatstone FRS FRSE DCL LLD (6 February 1802 – 19 October 1875), was an English scientist and inventor of many scientific breakthroughs of the Victorian era, including the English concertina, the stereoscope (a device for di ...
, but bears the name of Lord Playfair for promoting its use. The technique encrypts pairs of letters (''
bigram A bigram or digram is a sequence of two adjacent elements from a string of tokens, which are typically letters, syllables, or words. A bigram is an ''n''-gram for ''n''=2. The frequency distribution of every bigram in a string is commonly used f ...
s'' or ''digrams''), instead of single letters as in the simple
substitution cipher In cryptography, a substitution cipher is a method of encrypting in which units of plaintext are replaced with the ciphertext, in a defined manner, with the help of a key; the "units" may be single letters (the most common), pairs of letters, tri ...
and rather more complex
Vigenère cipher The Vigenère cipher () is a method of encrypting alphabetic text by using a series of interwoven Caesar ciphers, based on the letters of a keyword. It employs a form of polyalphabetic substitution. First described by Giovan Battista Bella ...
systems then in use. The Playfair is thus significantly harder to break since the
frequency analysis In cryptanalysis, frequency analysis (also known as counting letters) is the study of the frequency of letters or groups of letters in a ciphertext. The method is used as an aid to breaking classical ciphers. Frequency analysis is based on ...
used for simple substitution ciphers does not work with it. The frequency analysis of bigrams is possible, but considerably more difficult. With 600 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.


History

The Playfair cipher was the first cipher to encrypt pairs of letters in cryptologic history. Wheatstone invented the cipher for secrecy in
telegraphy Telegraphy is the long-distance transmission of messages where the sender uses symbolic codes, known to the recipient, rather than a physical exchange of an object bearing the message. Thus flag semaphore is a method of telegraphy, whereas ...
, but it carries the name of his friend Lord Playfair, first Baron Playfair of St. Andrews, who promoted its use. The first recorded description of the Playfair cipher was in a document signed by Wheatstone on 26 March 1854. It was initially rejected by the
British Foreign Office The Foreign, Commonwealth & Development Office (FCDO) is a department of the Government of the United Kingdom. Equivalent to other countries' ministries of foreign affairs, it was created on 2 September 2020 through the merger of the Foreig ...
when it was developed because of its perceived complexity. Wheatstone offered to demonstrate that three out of four boys in a nearby school could learn to use it in 15 minutes, but the Under Secretary of the Foreign Office responded, "That is very possible, but you could never teach it to attachés." It was however later used for tactical purposes by
British British may refer to: Peoples, culture, and language * British people, nationals or natives of the United Kingdom, British Overseas Territories, and Crown Dependencies. ** Britishness, the British identity and common culture * British English, ...
forces in the
Second Boer War The Second Boer War ( af, Tweede Vryheidsoorlog, , 11 October 189931 May 1902), also known as the Boer War, the Anglo–Boer War, or the South African War, was a conflict fought between the British Empire and the two Boer Republics (the So ...
and in
World War I World War I (28 July 1914 11 November 1918), often abbreviated as WWI, was List of wars and anthropogenic disasters by death toll, one of the deadliest global conflicts in history. Belligerents included much of Europe, the Russian Empire, ...
and for the same purpose by the
British British may refer to: Peoples, culture, and language * British people, nationals or natives of the United Kingdom, British Overseas Territories, and Crown Dependencies. ** Britishness, the British identity and common culture * British English, ...
and
Australia Australia, officially the Commonwealth of Australia, is a sovereign country comprising the mainland of the Australian continent, the island of Tasmania, and numerous smaller islands. With an area of , Australia is the largest country by ...
ns during
World War II World War II or the Second World War, often abbreviated as WWII or WW2, was a world war that lasted from 1939 to 1945. It involved the World War II by country, vast majority of the world's countries—including all of the great power ...
. This was because Playfair is reasonably fast to use and requires no special equipment - just a pencil and some paper. A typical scenario for Playfair use was to protect important but non-critical secrets during actual combat e.g. the fact that an artillery barrage of smoke shells would commence within 30 minutes to cover soldiers' advance towards the next objective. By the time enemy cryptanalysts could decode such messages hours later, such information would be useless to them because it was no longer relevant. During World War II, the
Government of New Zealand , background_color = #012169 , image = New Zealand Government wordmark.svg , image_size=250px , date_established = , country = New Zealand , leader_title = Prime Minister Jacinda Ardern , appointed = Governor-General , main_organ = , ...
used it for communication among
New Zealand New Zealand ( mi, Aotearoa ) is an island country in the southwestern Pacific Ocean. It consists of two main landmasses—the North Island () and the South Island ()—and over 700 smaller islands. It is the sixth-largest island coun ...
, the
Chatham Islands The Chatham Islands ( ) (Moriori: ''Rēkohu'', 'Misty Sun'; mi, Wharekauri) are an archipelago in the Pacific Ocean about east of New Zealand's South Island. They are administered as part of New Zealand. The archipelago consists of about t ...
, and the
coastwatchers The Coastwatchers, also known as the Coast Watch Organisation, Combined Field Intelligence Service or Section C, Allied Intelligence Bureau, were Allied military intelligence operatives stationed on remote Pacific islands during World War II ...
in the Pacific Islands.
Coastwatchers The Coastwatchers, also known as the Coast Watch Organisation, Combined Field Intelligence Service or Section C, Allied Intelligence Bureau, were Allied military intelligence operatives stationed on remote Pacific islands during World War II ...
established by
Royal Australian Navy The Royal Australian Navy (RAN) is the principal naval force of the Australian Defence Force (ADF). The professional head of the RAN is Chief of Navy (CN) Vice Admiral Mark Hammond AM, RAN. CN is also jointly responsible to the Minister o ...
Intelligence also used this cipher.


Superseded

Playfair is no longer used by military forces because of the advent of digital encryption devices. This cipher is now regarded as insecure for any purpose, because modern computers could easily break it within microseconds. The first published solution of the Playfair cipher was described in a 19-page pamphlet by Lieutenant Joseph O. Mauborgne, published in 1914. William Friedman described it in 1942 as providing very little security.


Description

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 (a modified Polybius square) 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 "J" or "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 break the message into digrams (groups of 2 letters) such that, for example, "HelloWorld" becomes "HE LL OW OR LD". These digrams will be substituted using the key table. Since encryption requires pairs of letters, messages with an odd number of characters usually append an uncommon letter, such as "X", to complete the final digram. The two letters of the digram are considered opposite corners of a rectangle in the key table. To perform the substitution, 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 letter, itself uncommon as a repeated pair, 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 letter of the encrypted pair is the one that lies on the same row as the first letter of the plaintext pair. To decrypt, use the ''inverse'' (opposite) of the two shift rules, selecting the letter to the left or upwards as appropriate. The last rule remains unchanged, as the transformation switches the selected letters of the rectangle to the opposite diagonal, and a repeat of the transformation returns the selection to its original state. The first rule can only be reversed by dropping any extra instances of the chosen insert letter — generally "X"s or "Q"s — that do not make sense in the final message when finished. There are several minor variations of the original Playfair cipher.


Example

Using "playfair example" as the key (assuming that I and J are interchangeable), the table becomes (omitted letters in red): The first step of encrypting the message "hide the gold in the tree stump" is to convert it to the pairs of letters "HI DE TH EG OL DI NT HE TR EX ES TU MP" (with the null "X" used to separate the repeated "E"s). Then: Thus the message "hide the gold in the tree stump" becomes "BM OD ZB XD NA BE KU DM UI XM MO UV IF", which may be restructured as "BMODZ BXDNA BEKUD MUIXM MOUVI F" for ease of reading the cipher text.


Clarification with picture

Assume one wants to encrypt the digram OR. There are five general cases:


Cryptanalysis

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 In cryptography, plaintext usually means unencrypted information pending input into cryptographic algorithms, usually encryption algorithms. This usually refers to data that is transmitted or stored unencrypted. Overview With the advent of comp ...
and
ciphertext In cryptography, ciphertext or cyphertext is the result of encryption performed on plaintext using an algorithm, called a cipher. Ciphertext is also known as encrypted or encoded information because it contains a form of the original plaintex ...
are known. When only the ciphertext is known, brute force
cryptanalysis Cryptanalysis (from the Greek ''kryptós'', "hidden", and ''analýein'', "to analyze") refers to the process of analyzing information systems in order to understand hidden aspects of the systems. Cryptanalysis is used to breach cryptographic s ...
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. 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," o
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''. A detailed cryptanalysis of Playfair is undertaken in chapter 28 of Dorothy L. Sayers' mystery novel ''
Have His Carcase ''Have His Carcase'' is a 1932 locked-room mystery by Dorothy L. Sayers, her seventh novel featuring Lord Peter Wimsey and the second in which Harriet Vane appears. Plot During a hiking holiday on the South West coast of England, the detec ...
''. 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. 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 The term ''pro forma'' (Latin for "as a matter of form" or "for the sake of form") is most often used to describe a practice or document that is provided as a courtesy or satisfies minimum requirements, conforms to a norm or doctrine, tends to ...
messages, they were broken at
Bletchley Park Bletchley Park is an English country house and estate in Bletchley, Milton Keynes (Buckinghamshire) that became the principal centre of Allied code-breaking during the Second World War. The mansion was constructed during the years following ...
. 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

Advanced thematic
cryptic crosswords A cryptic crossword is a crossword, crossword puzzle in which each clue is a word puzzle. Cryptic crosswords are particularly popular in the United Kingdom, where they originated, Ireland, Israel, the Netherlands, and in several Commonwealth of Na ...
like ''The Listener'' Crossword (published in the Saturday edition of the British newspaper ''
The Times ''The Times'' is a British daily national newspaper based in London. It began in 1785 under the title ''The Daily Universal Register'', adopting its current name on 1 January 1788. ''The Times'' and its sister paper '' The Sunday Times'' ( ...
'') occasionally incorporate Playfair ciphers.Listener crossword database
/ref> 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.


In popular culture

*The novel ''
Have His Carcase ''Have His Carcase'' is a 1932 locked-room mystery by Dorothy L. Sayers, her seventh novel featuring Lord Peter Wimsey and the second in which Harriet Vane appears. Plot During a hiking holiday on the South West coast of England, the detec ...
'' by Dorothy L. Sayers gives a blow-by-blow account of the cracking of a Playfair cipher. *The World War 2 thriller ''The Trojan Horse'' by
Hammond Innes Ralph Hammond Innes (15 July 1913 – 10 June 1998) was a British novelist who wrote over 30 novels, as well as works for children and travel books. Biography Innes was born in Horsham, Sussex, and educated at Feltonfleet School, Cobham, Surrey ...
conceals the formula for a new high-strength metal alloy using the Playfair cipher. *In the film '' National Treasure: Book of Secrets'', a treasure hunt clue is encoded as a Playfair cipher. *In the audio book '' Rogue Angel'' '': God of Thunder'', a Playfair cipher clue is used to send Anja Creed to Venice. *In the novel ''York: The Map of Stars'' (part three of a trilogy for children) by Laura Ruby, a clue to solving the Morningstarr cipher is encrypted using the Playfair cipher. * The Playfair cipher serves as a plot device in a season 2 episode of the 2019
Batwoman (TV series) Batwoman is a name used by several characters of DC Comics, both in mainstream continuity and Elseworlds. The best known Batwomen are Kathy Kane and Kate Kane. History * The first Batwoman, Kathy Kane, debuted during the Silver Age of Comics ...
.


See also

*
Topics in cryptography The following outline is provided as an overview of and topical guide to cryptography: Cryptography (or cryptology) – practice and study of hiding information. Modern cryptography intersects the disciplines of mathematics, computer scien ...


Notes


References

* * Smith, Michael ''Station X: The Codebreakers of Bletchley Park'' (1998, Channel 4 Books/Macmillan, London) *


External links


Online encrypting and decrypting Playfair with JavaScript


* ttp://rumkin.com/tools/cipher/playfair.php Playfair Cypher
Cross platform implementation of Playfair cipher

Javascript implementation of the Playfair cipher

Python and streamlit implementation of Playfair cipher
{{Cryptography navbox , classical Classical ciphers English inventions