Playfair Cipher Implementation in C

The Playfair cipher is a manual symmetric encryption technique and was the first literal digram 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 do not cover operation of the Playfair cipher. We suggest to go through very simple explanation given on Wikipedia for detailed step-by-step explanation.
 

 
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 cipher text.)

 

 

 
Above program is tested in Windows environment using Code::Blocks 16.01.

 
Thanks for reading.

Please use our online compiler to post code in comments.
Like us? Please spread the word and help us grow. Happy coding đŸ™‚
 



Leave a Reply

avatar
  Subscribe  
Notify of