Playfair Cipher Example

Using the keyword "COMPUTER", the key table would be initialized to

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

Let's encrypt the message "Hi there Mary". Change to upper-case, remove the spaces, and since the message has an odd number of character, append an 'X' -- "HITHEREMARYX". Now, encrypt two letters at a time.

  1. Locate 'H' and 'I' in the table. Since they are in the same row, encrypt them as the letters to their immediate right. 'H' becomes 'I'. Since 'I' is in the last column, wrap around to the first column so that 'I' becomes 'D'. So HI is encrypted as ID.
  2. Locate 'T' and 'H' in the table. Since they are not in the same row or same column, consider them as corners of a rectangle. 'T' is first encrypted as the corner of the rectangle made up of 'T's row, and 'H's column. 'T' becomes 'A'. Similarly, encrypt 'H' as the letter in 'H's row, but 'T's column. 'H' becomes 'D'. So TH is encrypted as AD.
  3. Locate 'E' and 'R' in the table. Since they are in the same row, encrypt them as the letters to their immediate right. 'E' becomes 'R' and 'R' becomes 'A'. so ER becomes RA.
  4. Locate 'E' and 'M' in the table. Since they are not in the same row or same column, consider them as coners of a rectangle. 'E' is first encrypted as the corner of the rectanlge made up of 'E's row and 'M's column. 'E' becomes 'R'. Simarilarly, encryprt 'M' using the intersection of 'Ms row and 'E's column. 'M' becomes 'O'. So EM becomes RO.
  5. Locate 'A' and 'R'. Since ther are in the same row, encrypt them as the letters to their immediate right. 'A' becomes 'B' and 'R' becomes 'A'. So AR becomes BA.
  6. Finally, since the last pair contains an 'X', they are not changed. 'YX' remains 'YX'
So when complete, the message "Hi there Mary" becomes ID AD RA RO BA YX

Try these other pairs using the matrix above.

  1. TR (same row)
  2. OF (same column)
  3. PY (same column)
  4. RB (same row)
  5. FQ (not same row, column)
  6. PD (not same row, column)
  7. FL (not same row, column)