In the Playfair cipher, we encrypt multiple letters of the plaintext. We use a 5x5 matrix of letters constructed using a keyword.

  1. Construct matrix by filling it with the letters of the keyword (minus the duplicates) from left to right and top to bottom. Then fill remaining letters in alphabetic order, where I and J count as one letter.
  2. Plaintext is encrypted two letters at a time:
    • If a pair is a repeated letter, we insert a filler character. “BALLOON” “BA LX LO ON”
    • If both letters fall in the same row, replace each letter with letter to right, wrapping back to start from end. (“AR” is encrypted as “RM”)
    • If both letters fall in the same column, replace each with letter below it, wrapping to top from bottom. (“MU” is encrypted as “CM”)
    • Otherwise, each letter is replaced by the letter in the same row and in the column of the other letter of the pair. (“HS” => “BP”, “EA” => “IM”/“JM”)
  3. To decrypt, use inverse of rules 2 and 3, and using 1st and 4th rules as-is.