LST 1402 Playfair Cipher
LST 1402 Playfair Cipher
Chris Christensen
MAT/CSC 483
Often today polygraphic ciphers are called block ciphers because they
encrypt blocks of plaintext with blocks of ciphertext.
1
modern sanitation. He lived across London's Hammersmith Bridge from
Wheatstone. Because both were short and bespectacled, they were
frequently mistaken for one another – once even by Lady Wheatstone. They
walked together on Sundays and amused themselves by solving enciphered
messages in the London Times. They easily read the correspondence of an
Oxford student with this young lady in London, and when the student
proposed an elopement, Wheatstone inserted an advertisement in the same
cipher remonstrating with her. The following a frantic "Dear Charlie: Write
no more. Our cipher is discovered!" – and then silence.
2
hastily constructed a keysquare based upon PALMERSTON to illustrate the
cipher at Granville's dinner.
P A L M E
R S T O N
B C D F G
H IJ K Q U
V W X Y Z
Kahn, David, The Codebreakers: The comprehensive history of secret communication from ancient times to
the internet, Scribner, 1996.
Cryptography
Here is how the cryptography works. We select a keyword, say (the name of
my favorite mathematician) Galois. The Playfair cipher uses a 5 × 5 square.
This method permits the encryption of 5 × 5 = 25 letters. This is a bit of a
problem because our alphabet contains 26 letters; so, two letters are
combined in the same cell of the square – usually I and J. Beginning with
the first row, enter the keyword from left to right skipping letters previously
used and continuing on to the second (or third or fourth or fifth) row if
necessary. After entering the keyword, the remaining letters of the alphabet
are entered in order. Here is the square we would obtain.
G A L O IJ
S B C D E
F H K M N
P Q R T U
V W X Y Z
3
situation, an x is inserted between double letters prior to encrypting. (This is
a dangerous weakness to the Playfair Cipher.) Here are the digrams of the
plaintext:
co ms ec me an sc om mu ni ca ti on sx
se cu ri ty
1. If both letters of the diagram lie in the same row, then each letter is
encrypted by the letter immediately to its right (cycling back to the first
letter in the row, if needed). For example,
2. If both letters of the diagram lie in the same column, then each letter is
encrypted by the letter immediately below it (cycling back to the first letter
in the column, if needed). For example,
It might help to picture the key square rolled into a torus -- a doughnut.
4
The message, written as a single string would be encrypted as
DLFDSDNDIHBDDTNTUEBLUOIMCVBSERULYO
More History
Decryption
Kahn, in his discussion of the Playfair Cipher, points out several advantages
of the digraphic (enciphering letter pairs) ciphers:
5
2. Long texts are pluses for cryptanalysis, but digraphic ciphers halve the
number of elements available for frequency analysis. In the message above,
there are 17 digraphic substitutions rather than 34 single-letter substitutions.
We will do a known plaintext attack on it. Recall that because the Playfair
cipher encrypts digraphs typically longer ciphertexts are needed to
successfully cryptanalyze the message.
co mx ma nd er in ch ie fx fl ex et to na va lh ea dq ua rt
BP LY KR LH FE KI DB NF VU VI VZ HZ OP KE RV ND FV LX WF ES
er s_
FE YS PT ON LY NR BL EP HZ SF TA BQ BN SE MB NZ VA QZ
This happens to be the correct placement of the plaintext, but there are a
couple of ways to match up plaintext and ciphertext for a message
enciphered with a Playfair cipher:
6
Reversed plaintext digraphs correspond to reversed ciphertext
digraphs; e.g, if er = DM, then re = MD. There are no reversals in the
plaintext given above.
* * * letter *
*
We begin with the first pair of digraphs: co = BP; c goes to B and o goes
to P. Recall how the Playfair cipher enciphers messages. There are 3
possibilities; the following gives one example of each type.
c B c c B o P
or B or
P o o
P
7
B c
, and we do not know the location of the 4 letters in
o P
the column in case 2 nor the location of the 4 letters in the row in case 3.
t
either something like O or .
P t O P
When we try to merge one of these squares with one of the first squares, it
c B
seems that if the square is rearranged to
P o
8
B c
, it can be merged with .
o P t O P
It’s likely that in both rows we are seeing alphabetical order. Because O is
to the right of t, it appears that t is the last entry in the row and O is the first
B C
entry. . Between P and T there are spots for 2 letters –
O P T
Notice that et = HZ. Let’s play a hunch that Z will occur in the bottom
right of the square. Then it would appear that in the last column we would
have
e
H
t
Z
E
B C H
So, probably .
O P T
Z
In the last row, there is space for 4 letters; between T and Z we would have
U, V, W, X, Y. One of these letters must be in the keyword. It also
9
appears that F is in the keyword. So, in the keyword is F, one of Q, R, S
and one of U, V, W, X, Y.
Now notice that ea = FV. F should be in the first row. Because E is also,
it appears that e, a, F, and V are all in the first row – in the keyword -- in
this order eFaV. The last row must be U, W, X, Y, Z. F must follow
e; so, F must be the first letter of the row, and a must follow F. So, the first
row is FAV_E or F_AVE. r must be in the first row and we must have
FAVRE.
F A V R E
B C D G H
The square is I J K L M N .
O P Q S T
U W X Y Z
Double Playfair
During World War II, (starting in mid-1941) the German Army and the SD
(Sicherheitsdienst, the Nazi party and the government political police) used a
double Playfair Cipher for hand encryption. The ciphers were regularly
broken by the British cryptologists at Bletchley Park.
Two squares are used. Each could have a keyword, but in practice the
Germans used two squares of randomly arranged letters. (Therefore, it was
necessary to have a written key.) The squares below are constructed using
keywords; the keywords are Galois and Seagrave.
G A L O IJ S E A G R
S B C D E V B C D F
F H K M N H IJ K L M
P Q R T U N O P Q T
V W X Y Z U W X Y Z
10
The encryption method is similar to that for a single Playfair square. The
first letter of the digraph is located in the square on the left and the second
letter of the digraph is located in the square on the right. A rectangle is
constructed. Etc. Obviously, letters cannot be in the same column, but they
can still be in the same row. Several schemes are used in such cases. Let us
agree to take the letter to the right of the plaintext letter (returning back to
the beginning of the row of that square) if necessary.
Notice that there are some differences between Playfair and Double Playfair:
Larger Blocks
All of the advantages of digraphic ciphers are strengthened if the block size
is increased. In particular, frequency analysis would be even more difficult
if the blocks were larger. There are 263 = 17576 trigraphs; there are
264 = 456976 quadragraphs, etc.
11
Exercises
1. The following was encrypted with a Playfair Cipher with keyword Galois.
Decrypt the message.
AQOUNGCIEYEOKVNGBIMEHOTUEUNBCLOKIH
4. Use the double Playfair Cipher constructed above to encrypt the message:
12
5. Here is a four-square cipher. Keywords are used to fill the square in the
upper right corner and the lower left corner; traditionally alphabetical order
is used for the other two squares. Locate the first letter of each digraph in
the upper left square, and locate the second letter of each digraph in the
lower right square.
a b c d e S E A G R
f g h i j k V B C D F
l m n o p H IJ K L M
q r s t u N O P Q T
v w x y z U W X Y Z
P L A Y F a b c d e
IJ R B C D f g h i j k
E G H K M l m n o p
N O Q S T q r s t u
U V W X Z v w x y z
13
7. Assuming that the 25 symbols a b c d e f g h i/j k l m n o
p q r s t u v w x y z are randomly assigned to the cells of a 5 × 5
square, how many such squares are possible?
14
8. Here are some of the plaintext and corresponding ciphertext
substitutions for a Playfair cipher. These are all the digraphs with f on the
right. Try to reconstruct the square. Is there any ambiguity in the
construction of the square?
Plaintext Ciphertext
af MC
bf CG
cf DG
df FG
ef MG
gf BG
hf QB
if QC
kf QD
lf MD
mf OQ
nf OG
of FQ
pf MB
qf YQ
rf OB
sf OC
tf OD
uf QG
vf YB
wf YC
xf YD
yf MQ
zf YG
15
9. The following has been encrypted with a Playfair cipher. Here’s the
known plaintext. Determine the Playfair square!
th ep ro bl em of en su ri ng th es ec
UG CT QD FK GT DB SM HZ PL MH UG SC SO
ur it yo fm es sa ge sw as co ns id er
PT MP WE GL SC CH MG OZ HC DC UH LC DT
ed by th ea nc ie nt gr ex ek sa nd by
SE GW UG CG IS MC MU FT DY OM CH LS GW
ju li us ca es ar am on go th er sx
NP MK ZH AI SC FP GI SK BE UG DT DZ
10. Determine the Playfair square for the following message that was
enciphered with a Playfair cipher.
16
11. The ciphertext message was encrypted using a Playfair cipher.
Determine the key square. What is the keyword?
Known plaintext
Corresponding ciphertext
17