Enigma Machine

Enigma Machine
German Enigma Machine

Sunday, May 24, 2009

Polyalphabetic Ciphers - Playfair

Polyalphabetic Ciphers - Playfair

Polygraphic ciphers allow the encoding of multiple characters at one time (rather than substituting a single character at a time). There are a number of schemes that encode 2 or more characters simulataneously. One of the most popular of these is the Playfair cipher.

Playfair used a 5x5 box of characters. A keyword is chosen (with all unique characters.) The remaining characters of the alphabet are listed in alphabetical order left to right and top to bottom. One more note, the 5x5 box fits only 25 charcters. The letters i and j share a cell. As an example, using the keyword sleuth, the box would be:

S L E U T
H A B C D
F G IJ K M
N O P Q R
V W X Y Z

The message to be encoded, is divided into pairs of letters. These pairs are called a digraph. If there is a repeated letter in a digraph, an x is inserted between the letters and the digraphs are reorganized. Also, in cases where the messages have an odd number of characters, an x is added at the end.

Now, there are three different ways the letters can be related in the 5x5 encoding box. They can:
1.Both be in the same row
2.Both be in the same column
3.Be neither in the same row nor the same column.

If they are in the same row, substitute the next character in that row for each of the two characters. If you are at the end of a row, wrap around to the first character in the same row. Thus, UT becomes TS.

If the letters are in the same column, use the character below each letter in the box. If the letter is at the bottom of a column, use the character at the top of the column. For example, GO becomes OW.

If the letters are in different rows and different columns, then do the following:
1.Starting at the first letter, scan across the row until you are in the same column as the second letter (remember you can wrap around to the beginning of the row if this letter is further 'right' in the box). Use that letter as the ciphertext.
2.Starting at the second letter, scan across its row until you are in the same column as the first letter (again wrapping around if necessary).

Here is an example of encoding that digraph: If you have NE as your plain text, start with N and travel to the right until you are in the same column as E (column 3). The letter is P. Now starting at E, scan to the right (and wrap around) to end over the letter N (column 1). The letter is S. So NE becomes PS.
Note that in this case, the two plaintext letters and the resulting ciphertext letters form a small box within the 5x5 encoding box.

Let's try a full message. With the keyword SLEUTH, we now encrypt the message:
This is so silly. It is elementary my dear watson.

Removing punctuation and pairing letters, we get:
TH IS IS SO SI LX LY IT IS EL EM EN TA RY MY DE AR WA TS ON

And the resulting cipher is:

SD FE FE LN EF EW UW ME FE UE TI SP LD QZ KZ BT DO LG SL PO

Regrouping as we should in collections of 5 letters we get:

SDFEF ELNEF EWUWM EFEUE TISPL DQZKZ BTDOL GSLPO

This is quite a mess, but a cryptanalyst does have some ways to try and break the encoding. We will look at those techniques in a future column.

No comments: