-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathplayfair_explain.txt
20 lines (10 loc) · 1.44 KB
/
playfair_explain.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
The Playfair cipher was the first practical digraph substitution cipher.
Rules to encrypt the cipher are:
1.Remove any punctuation or characters that are not present in the key square (this may mean spelling out numbers, punctuation etc.).
2.Identify any double letters in the plaintext and replace the second occurence with an 'x' e.g. 'hammer' -> 'hamxer'.
3.If the plaintext has an odd number of characters, append an 'x' to the end to make it even.
4.Break the plaintext into pairs of letters, e.g. 'hamxmer' -> 'ha mx me rx'. The algorithm now works on each of the letter pairs.
5.Locate the letters in the key square.
6.If the letters are in different rows and columns, replace the pair 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.
7.If the letters appear on the same row of the 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).
8.If the letters appear on the same column of the 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).