Monday, October 14, 2013

Code 15 : Playfair Cipher

The Playfair cipher encrypts pairs of letters (digraphs), instead of single letters. This is significantly harder to break since the frequency analysis used for simple substitution ciphers is considerably more difficult.
Memorization of the keyword and 4 simple rules is all that is required to create the 5 by 5 table and use the cipher.
K E Y W O
R D A B C
F G H I J
L M N P S
T U V X Z
The Playfair cipher uses a 5 by 5 table containing a key word or phrase. To generate the table, one would first fill in the spaces of the table 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 (to reduce the alphabet to fit you can either omit "Q" or replace "J" with "I"). In the example to the right, the keyword is "keyword".
To encrypt a message, one would break the message into groups of 2 letters. If there is a dangling letter at the end, we add an X. For example. "Secret Message" becomes "SE CR ET ME SS AG EX". We now take each group and find them out on the table. Noticing the location of the two letters in the table, we apply the following rules, in order.
  1. If both letters are the same, add an X between them. Encrypt the new pair, re-pair the remining letters and continue.
  2. 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 necessary. For example, using the table above, the letter pair GJ would be encoded as HF.
  3. If the letters appear on the same column of your table, replace them with the letters immediately below, wrapping around to the top if necessary. For example, using the table above, the letter pair MD would be encoded as UG.
  4. If the letters are on different rows and columns, 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 pair should be replaced first. For example, using the table above, the letter pair EB would be encoded as WD.
To decipher, ignore rule 1. In rules 2 and 3 shift up and left instead of down and right. Rule 4 remains the same. Once you are done, drop any extra Xs that don't make sense in the final message and locate any missing Qs or any Is that should be Js.

The Playfair cipher is a digraph substitution cipher. It employs a table where one letter of the alphabet is omitted, and the letters are arranged in a 5x5 grid. Typically, the J is removed from the alphabet and an I takes its place in the text that is to be encoded. Below is an unkeyed grid.
A B C D E
F G H I K
L M N O P
Q R S T U
V W X Y Z
To encode a message, one breaks it into two-letter chunks. Repeated letters in the same chunk are usually separated by an X. The message, "HELLO ONE AND ALL" would become "HE LX LO ON EA ND AL LX". Since there was not an even number of letters in the message, it was padded with a spare X. Next, you take your letter pairs and look at their positions in the grid.
"HE" forms two corners of a rectangle. The other letters in the rectangle are C and K. You start with the H and slide over to underneath the E and write down K. Similarly, you take the E and slide over to the H column to get C. So, the first two letters are "KC". "LX" becomes "NV" in the same way.
"LO" are in the same row. In this instance, you just slide the characters one position to the right, resulting in "MP". The same happens for "ON", resulting in "PO". "EA" becomes "AB" in the same way, but the E is at the far edge. By shifting one position right, we scroll around back to the left side and get A.
"ND" are in a rectangle form and beomes "OC". "AL" are both in the same column, so we just move down one spot. "AL" is changed into "FQ". "LX" is another rectangle and is encoded as "NV".
The resulting message is now "KC NV MP PO AB OC FQ NV" or "KCNVMPPOABOCFQNV" if you remove the spaces.
This encoder will do all of the lookups for you, but you still need to do a few things yourself.
  1. Manually break apart double letters with X (or any other) characters. Some people break apart all doubles, others break all doubles that happen in the same two-letter chunk. This encoder requires neither in order to be more flexible.
  2. Manually make the message length even by adding an X or whatever letter you want. If you don't, the encoder will automatically add an X for you.
All non-letters are ignored and not encoded. The one letter that you select to share a square in the cipher is translated. Numbers, spaces, and punctuation are also skipped. If you leave two letters together in a two-letter chunk, they will be encoded by moving down and right one square ("LL" becomes "RR") where as traditional Playfair ciphers will automatically insert an X for you.
This particular cipher was used by the future U.S. President, John F. Kennedy, Sr. He sent a message about a boat going down.
 
Playfair Cipher

The Playfair cipher is a digraph substitution cipher. It employs a table where one letter of the alphabet is omitted, and the letters are arranged in a 5x5 grid. Typically, the J is removed from the alphabet and an I takes its place in the text that is to be encoded. Below is an unkeyed grid.
A B C D E
F G H I K
L M N O P
Q R S T U
V W X Y Z
To encode a message, one breaks it into two-letter chunks. Repeated letters in the same chunk are usually separated by an X. The message, "HELLO ONE AND ALL" would become "HE LX LO ON EA ND AL LX". Since there was not an even number of letters in the message, it was padded with a spare X. Next, you take your letter pairs and look at their positions in the grid.
"HE" forms two corners of a rectangle. The other letters in the rectangle are C and K. You start with the H and slide over to underneath the E and write down K. Similarly, you take the E and slide over to the H column to get C. So, the first two letters are "KC". "LX" becomes "NV" in the same way.
"LO" are in the same row. In this instance, you just slide the characters one position to the right, resulting in "MP". The same happens for "ON", resulting in "PO". "EA" becomes "AB" in the same way, but the E is at the far edge. By shifting one position right, we scroll around back to the left side and get A.
"ND" are in a rectangle form and beomes "OC". "AL" are both in the same column, so we just move down one spot. "AL" is changed into "FQ". "LX" is another rectangle and is encoded as "NV".
The resulting message is now "KC NV MP PO AB OC FQ NV" or "KCNVMPPOABOCFQNV" if you remove the spaces.
This encoder will do all of the lookups for you, but you still need to do a few things yourself.
  1. Manually break apart double letters with X (or any other) characters. Some people break apart all doubles, others break all doubles that happen in the same two-letter chunk. This encoder requires neither in order to be more flexible.
  2. Manually make the message length even by adding an X or whatever letter you want. If you don't, the encoder will automatically add an X for you.
All non-letters are ignored and not encoded. The one letter that you select to share a square in the cipher is translated. Numbers, spaces, and punctuation are also skipped. If you leave two letters together in a two-letter chunk, they will be encoded by moving down and right one square ("LL" becomes "RR") where as traditional Playfair ciphers will automatically insert an X for you.
This particular cipher was used by the future U.S. President, John F. Kennedy, Sr. He sent a message about a boat going down.

Translate the letter into
Encode double letters (down and right one spot)
Alphabet Key: - Show Keymaker
Tableau Used:    R O Y A L
N E W Z D
V B C F G
H I K M P
Q S T U X
Your message:

Add Spaces - Adds a space after every other letter (only A-Z count) so you can see the letter pairs.
Only Letters - Removes all non-letters from the text.
This is your encoded or decoded text:
PT BOAT ONE OWE NINE LOST IN ACTION IN BLACKETT STRAIT TWO MILES SW MERESU COCE X CREW OF TWELVE X REQUEST ANY INFORMATION X
Welcome each day as a fresh new beginning.Tyler Akins <fidian@rumkin.com>
Contact Me - Legal Info


0 comments:

Post a Comment

Note: Only a member of this blog may post a comment.