Playfair cipher
by fortenforge, Nov 29, 2009, 5:54 AM
So in 1845, this guy named Charles Wheatstone invented this cipher. It is called the Playfair cipher because Lord Playfair popularized it. It was used during WWI and WWII. Here is how it works:
Let us say that we have the plaintext:
THREEFEETINONEYARD
We first split it into digraphs, (groups of 2)
TH RE EF EE TI NO NE YA RD
If there are pairs with double letters, put an X in between the letters and re-pair the letters.
TH RE EF EX ET IN ON EY AR D
If the end group is a single letter attach an X to it.
TH RE EF EX ET IN ON EY AR DX
Also, if you have any J's replace them with I's
Now, choose a key word, such as GEOGEBRA.
Create a 5 by 5 table of all the letters in the English language with the letters in the key word coming first, deleting any repeated letters:
G E O B R
A C D F H
I K L M N
P Q S T U
V W X Y Z
For each group, find the equivalent ciphertext digraph using these rules.
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.
OK, lets try this for our plaintext.
TH RE EF EX ET IN ON EY AR DX
G E O B R
A C D F H
I K L M N
P Q S T U
V W X Y Z
The first group is TH, T and H are not on the same row or column so we find the letter that is on the same row as T and on the same column as H, it turns out to be U, then we find the letter that is on the same row as H, and on the same column as T, it turns out to be F. The corresponding ciphertext digraph is then UF.
The second group is RE, R and E are on the same row and column so we first take the letter immediately to the right of R, G then we take the letter immediately to the right of E, O. The corresponding digraph is then GO.
You get the idea, the resulting ciphertext is:
UF GO BC OW BQ KI RL BW HG LO.
Let us say that we have the plaintext:
THREEFEETINONEYARD
We first split it into digraphs, (groups of 2)
TH RE EF EE TI NO NE YA RD
If there are pairs with double letters, put an X in between the letters and re-pair the letters.
TH RE EF EX ET IN ON EY AR D
If the end group is a single letter attach an X to it.
TH RE EF EX ET IN ON EY AR DX
Also, if you have any J's replace them with I's
Now, choose a key word, such as GEOGEBRA.
Create a 5 by 5 table of all the letters in the English language with the letters in the key word coming first, deleting any repeated letters:
G E O B R
A C D F H
I K L M N
P Q S T U
V W X Y Z
For each group, find the equivalent ciphertext digraph using these rules.
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.
OK, lets try this for our plaintext.
TH RE EF EX ET IN ON EY AR DX
G E O B R
A C D F H
I K L M N
P Q S T U
V W X Y Z
The first group is TH, T and H are not on the same row or column so we find the letter that is on the same row as T and on the same column as H, it turns out to be U, then we find the letter that is on the same row as H, and on the same column as T, it turns out to be F. The corresponding ciphertext digraph is then UF.
The second group is RE, R and E are on the same row and column so we first take the letter immediately to the right of R, G then we take the letter immediately to the right of E, O. The corresponding digraph is then GO.
You get the idea, the resulting ciphertext is:
UF GO BC OW BQ KI RL BW HG LO.