The Playfair cipher is a manual symmetric encryption technique and was the first literal diagram substitution cipher. The technique encrypts pairs of letters, instead of single letters as in the simple substitution cipher and rather more complex Vigenère cipher systems then in use. The Playfair is thus significantly harder to break since the frequency analysis used for simple substitution ciphers does not work with it.

This article does not cover the operation of the Playfair cipher. We suggest going through the simple explanation given on Wikipedia for a detailed step-by-step explanation.

 
Implementation:

Following is the implementation of Playfair cipher in C. The program expects two input files – Playfair.txt, which contains the plain text, and key.txt, which contains the key.

 
Use Playfair example as the key to encrypt the message HIDE THE GOLD IN THE TREE STUMP. After encryption, the message becomes BM OD ZB XD NA BE KU DM UI XM MO UV IF (Breaks included for ease of reading the ciphertext).

 
The above program is tested in the Windows environment using Code::Blocks 16.01.

That’s all about Playfair Cipher implementation in C.