01 What is the Playfair Cipher?

Playfair cipher – Wikipedia

The Playfair cipher is a monoalphabetic bigraphic substitution cipher. It was invented in 1854 by Charles Wheatstone and named after Lyon Playfair, who recommended this method to the British military.

The plaintext is written in bigrams. Only uppercase letters are used, any umlauts are seperated in e.g. ae, and spaces and punctuation are omitted. When forming the bigrams, care is taken that none are formed from two identical letters, such as “LL”. To avoid this, an “X” (or another rare letter such as “Q”) is inserted if necessary.
If a single letter occurs alone at the end of the text, it is expanded into a bigram by appending another “X” (or “Q”).

For encryption, a 5×5 square is formed using the keyword. The letters J, C and W are optionally replaced by I, K or VV.

The encryption of the bigrams is done according to the following rules:

If both letters are in the same column or in the same row, the lower or right neighboring letters are taken as secret letters. If the letters stand at the edge of the playfair square, it is simply continued at the other edge.
If, on the other hand, the two letters of the plaintext bigram are in different rows and columns, the first clear letter is replaced by the one in the same row but in the column of the second one. The second clear letter is replaced by the one in the same row but in the column of the first clear letter.


The decoding of the bigrams is done according to the following rules:

In cases where both plaintext letters are in the same column or row of the square, the upper or left neighbor, respectively, is selected, thus reversing the encryption step.
If, on the other hand, the two letters of the plaintext bigram are in different rows and columns, the first plaintext letter is replaced by the one in the same row but in the column of the second one. The second clear letter is replaced by the one in the same row but in the column of the first clear letter.