The PLAYFAIR cipher

Assume the keyword is "Magnetic". Write out the keyword and then the remaining letters of the alphabet in rows beneath the keyword:

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

Next, arrange the letters in a 5 by 5 square by taking the letters in column order from the above arrangement and placing the letters in order by rows. The letters I and J occupy the same position in the 5 by 5 grid:

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

Next write out the message to be enciphered in pairs. Double letters in a pair should be separated by the insertion of an "X". If the original message is:

MESSENGER CAPTURED

Then the letters would be prepared for encipherment as follows:

ME SX SE NG ER CA PT UR ED

Now, encipher each pair of letters using the 5 by 5 arrangement. The letters are replaced with other letters in the arrangement based on the positioning of the original pair of letters. The letters can stand in only one of three relationships to each other:

The letters appear in the same row
The letters appear in the same column
The letters are in different rows and columns

When the letters appear in the same row, replace each of them by the letter immediately to the right (if the letter is in the last column then "wrap around" to the letter in the first column of the row)

When the letters appear in the same column, replace each of them by the letter immediately beneath (if the letter is in the last row then "wrap around" to the letter in the first row of the column)

If the letters are neither in the same row or same column then replace each with the letter that is in the same row but in the other letter's column.

The message above would therefore be enciphered as:

AREOERSQRN  XPZCINRF

And would be transmitted as:

AREOE  RSQRN  XPZCI  NRF

So why did I choose Charles-Wheatstone as my current userid? Because Charles Wheatstone is the inventor of the Playfair cipher. It was named Playfair after Lyon Playfair, the first Baron Playfair of St. Andrews, the man who popularized it.

The Playfair Cipher is thought to be the first in history to be digraphic (that is, to encipher two letters so that the result depends upon both together).