Introduction
Whether it’s a startup or a conglomerate, data is the most precious asset for today’s businesses. Organizations use raw data to turn it into meaningful information for making vital business decisions. With so much power at its disposal, data can cost companies significantly if it falls into the wrong hands.
For the same reason, organizations take data management very seriously. Businesses protect their data with a range of means, including access restriction, data encryption, and using multiple overlapping monitoring systems in place. Playfair cipher offers data encryption and decryption to ensure data privacy. This guide explains everything about Playfair cipher, its advantages and disadvantages, its relevance, and the Playfair encryption and decryption algorithms with examples.
In this article let us look at:
 What is Playfair Cipher?
 Playfair Cipher’s Relevance
 Playfair Cipher Encryption and Decryption Algorithm
 Advantages and Disadvantages of Playfair Cipher
 Earlier Cryptographic Systems
1. What is Playfair Cipher?
Playfair cipher is the first and bestknown digraph substitution cipher, which uses the technique of symmetry encryption. Invented in 1854 by Charles Wheatstone, the cipher got its name from Lord Playfair, who promoted its use. Unlike single letters in a simple substitution cipher, the Playfair cipher technique encrypts digraphs or parts of letters.
The Playfair cipher is relatively fast and doesn’t require special equipment. British Forces used it for tactical purposes during World War I and the Second Boer War, and Australians utilized it during World War II. The primary use of the cipher was for protecting vital but noncritical secrets during actual combat. By the time the enemy cryptanalysts could decrypt the information, it was useless for them.
2. Playfair Cipher’s Relevance
The Playfair cipher was significantly popular in the World War I and II era because of its complexity level compared to the then available ciphers. Further, it didn’t need any special tools or equipment to encrypt or decrypt the information.
However, after the invention of computers, the Playfair cipher was no longer used, as the computers can solve Playfair ciphers in a few seconds using break codes. Due to this reason, with the advancement of digital encryption and the passage of time, Playfair cipher was no more an acceptable form of encoding messages as there was a risk of data getting into the wrong hands. Thus, Playfair cipher cannot be recommended for business organizations. Further, it’s a manual and laborcentric process that does not need any Playfair cipher calculator or decoder. However, there are Playfair cipher programs in C and Python.
3. Playfair Cipher Encryption and Decryption Algorithm
We will have a look at some examples of Playfair Cipher with encryption and decryption algorithms.
The Playfair cipher has a key and a plaintext. The key is in the form of a word which can be any sequence of 25 letters without repeats. We can build a ‘key square’ using this key.
Playfair Cipher Encryption Algorithm
The Playfair cipher encryption algorithm has two steps.
Generating the Key Square
 The ‘key square’ is a 5×5 grid consisting of alphabets that helps encrypt the plain text.
 All these 25 letters should be unique.
 Since the grid can accommodate only 25 characters, there is no ‘J’ in this table. Any ‘J’ in the plaintext is replaced by ‘I’.
 Remove any characters or punctuation that are not present in the key square. Instead, spell out the numbers, punctuations, and any other nonalphabetic text.
 The key square will start with the key’s unique alphabet in the order of appearance, followed by the alphabet’s remaining characters in order.
Encrypting the Plain Text
Before encrypting the text, you need to divide the Playfair cipher plaintext into digraphs – pairs of two letters. In the case of plaintext with an odd number of letters, add the letter ‘Z’ to the last letter. If there are any double letters in the plain text, replace the second occurrence of the letter with ‘Z’, e.g., ‘butter’ > ‘butzer’.
Rules for Playfair Cipher Encryption
 Case I – Both the letters in the digraph are in the same row – Consider the letters right of each alphabet. Thus, if one of the digraph letters is the rightmost alphabet in the grid, consider the leftmost alphabet in the same row.
 Case II – Both the letters in the digraph are in the same column – Consider the letters below each alphabet. Thus, if one of the digraph letters is the grid’s bottommost letter, consider the topmost alphabet in the same column.
 Case III – Neither Case I or II is true – Form a rectangle with the two letters in the digraph and consider the rectangle’s horizontal opposite corners.
Example of Playfair Cipher Encryption Algorithm
Let’s assume that our Playfair cipher key is “Hello World,” and the plaintext that we want to encrypt is “hide the gold”.
Step 1 – Creating the key square
Our key is “Hello World”. The first characters considering from left to right and after removing the duplicates are “helowrd” as we have removed the second l in “hello” and o and l from “world”. Now let’s fill the key square with these letters. We will fill the rest of the grid with the remaining letters in alphabet az without repeating any letters. Thus, our grid will look like this – *Please note that we have omitted J.
H  E  L  O  W 
R  D  A  B  C 
F  G  I  K  M 
N  P  Q  S  T 
U  V  X  Y  Z 
Creating the Digraph
We want to encrypt the text “hide the gold”, which has an odd number of alphabets. Hence, we want to pad it with ‘Z” at the end. After splitting it into digraphs, it will look like
HI DE TH EG OL DZ
Encryption Process
There are six digraphs in total. Let’s consider the first digraph HI and locate it in the table. H and I are neither in the same row or column. Hence, applying Case III from the “Rules of Playfair Cipher Encryption” section, we have to form the rectangle using H and I and identify the horizontal opposite corners, which are L and F.
H  E  L  O  W 
R  D  A  B  C 
F  G  I  K  M 
N  P  Q  S  T 
U  V  X  Y  Z 
So, the encryption for the first digraph HI > LF
Considering the second digraph DE, the letters are in the same column. Using Case II from the “Rules of Playfair Cipher Encryption” section, consider the letters below each of them.
H  E  L  O  W 
R  D  A  B  C 
F  G  I  K  M 
N  P  Q  S  T 
U  V  X  Y  Z 
So, the encryption for the digraph DE > GD
Using these rules, the encryption for the next two digraphs is as follows –
The encryption for the digraph TH > NW
The encryption for the digraph EG > DP
While encrypting the next digraph OL for which the letters lie in the same row, use Case I from the “Rules of Playfair Cipher Encryption” section, and consider the letters on the right of each of them.
H  E  L  O  W 
R  D  A  B  C 
F  G  I  K  M 
N  P  Q  S  T 
U  V  X  Y  Z 
Thus, the encryption for the digraph OL > WO
Using these rules, the encryption for the last digraph DZ > CV
We will summarize the digraph encryption as follows
HI > LF
DE > GD
TH > NW
EG > DP
OL > WO
DZ > CV
Thus, using Playfair cipher encryption rules, the encryption of “hide the gold” is “lfgdnwdpwocv”
Playfair Cipher Decryption Algorithm
The decryption of the Playfair cipher follows the same process in reverse. The receiver has the same key and key table and can decrypt the message using the key.
Rules for Playfair Cipher Decryption
 Case I – Both the letters in the digraph are in the same row – Consider the letters left of each alphabet. Thus, if one of the digraph letters is the leftmost letter in the grid, consider the rightmost alphabet in the same row.
 Case II – Both the letters in the digraph are in the same column – Consider the letters above each alphabet. Thus, if one of the digraph letters is the topmost letter in the grid, consider the bottommost alphabet in the same column.
 Case III – Neither Case I or II is true – Form a rectangle with the two letters in the digraph and consider the rectangle’s horizontal opposite corners.
Generating the Key Square
Generate the key square using the key texts and follow the same rules mentioned in the “Step 1 – Creating the key square” section of this example.
Creating the Digraph
The text that we want to decrypt is “lfgdnwdpwocv”. After splitting it into digraphs, it will look like
LF GD NW DP WO CV
Decryption Process
There are six digraphs in total. Let’s consider the first digraph LF and locate it in the table. Since L and F are neither in the same row or column, applying Case III from the “Rules of Playfair Cipher Decryption” section, we have to form the rectangle using L and F and identify the horizontal opposite corners – H and I.
H  E  L  O  W 
R  D  A  B  C 
F  G  I  K  M 
N  P  Q  S  T 
U  V  X  Y  Z 
So, the decryption for the first digraph LF > HI
In the second digraph GD, the letters are in the same column. Using Case II from the “Rules of Playfair Cipher Decryption” section, consider the letters above each alphabet.
H  E  L  O  W 
R  D  A  B  C 
F  G  I  K  M 
N  P  Q  S  T 
U  V  X  Y  Z 
So, the decryption for the digraph GD > DE
Using these rules, the decryption for the next two digraphs is as follows –
The decryption for the digraph NW > TH
The decryption for the digraph DP > EG
While decrypting the next digraph WO for which the letters lie in the same row, use Case I from the “Rules of Playfair Cipher Decryption” section and consider the letters on the left of each of them.
H  E  L  O  W 
R  D  A  B  C 
F  G  I  K  M 
N  P  Q  S  T 
U  V  X  Y  Z 
Thus, the decryption for the digraph WO > OL
Using these rules, the decryption for the last digraph CV > DZ
We will summarize the digraph decryption as follows
LF > HI
GD > DE
NW > TH
DP > EG
WO > OL
CV > DZ
Thus, using Playfair cipher decryption rules, the decryption of “lfgdnwdpwocv” is “hide the gold”.
4. Advantages and Disadvantages of Playfair Cipher
With its basic features, there are specific advantages and disadvantages of Playfair cipher.
Advantages of Playfair Cipher
 Relatively Difficult to Decrypt
Playfair cipher is secure and needs significant efforts to decrypt the message, making it relatively difficult to crack. At the same time, the complex mathematics behind it makes it equally difficult for the receiver to decode the information.
As the frequency analysis used for simple substitution cipher doesn’t work with the Playfair cipher, it is significantly trickier to break. Further, if one decides to undertake frequency analysis, it needs much more ciphertext on 25*25 = 625 possible digraphs than 25 possible monographs in the case of a simple substitution cipher.
 Safer Alternative
The encrypting and decrypting data in Playfair cipher is a manual method that eliminates the need for a Playfair cipher calculator. Without any need to use a Playfair cipher decoder, information can securely travel between its source and destination without getting into the wrong hands when you implement Playfair cipher encryptiondecryption in C.
Disadvantages of Playfair Cipher
 Symmetric Cryptography
As the Playfair cipher is a symmetric cipher, it uses the same key for encryption and decryption. One can easily crack symmetric cryptography through the Playfair cipher program technique. Also, the amount of encryption and decryption will be less.
 Not Useful for Huge Data Volume
One primary disadvantage of Playfair cipher is that you can’t use it to transmit massive data.
 Easy to Exploit
In the Playfair cipher, the substitution is selfinverse. It means that the digraph in the ciphertext (AB) and its reverse (BA) have corresponding plaintexts, such as RU and UR. Similarly, ciphertexts UR and RU have corresponding plaintexts AB and BA). One can easily exploit it using frequency analysis, provided he/she knows the language of the plaintext.
5. Earlier Cryptographic Systems
All the earlier cryptographic systems or ‘ciphers’ are designed based on the symmetric key encryption scheme. They worked on alphabets as the basic elements, unlike modern digital systems that treat data as binary numbers. Following are some of the earlier cryptographic systems besides the Playfair cipher.
 Caesar Cipher
Also referred to as the Shift cipher, Caesar cipher is the simplest type of substitution cipher scheme. Using this cipher, one can form a ciphertext by substituting each alphabet of plaintext by another letter, which is shifted by some fixed number lying between 0 and 25. However, it’s not a secure cryptosystem as there are only 26 possible keys to decrypt the plaintext, and an attacker can easily crack it with limited computing resources.
 Simple Substitution Cipher
This cipher utilizes some permutation of the letters in the alphabet. With 26 letters, the sender and receiver may select any of the 26! which is 4 x 10^{26} possible permutation as a ciphertext alphabet which is the secret key of the scheme. Despite the vast number of keys that the modern computing system can’t comfortably break, this cipher is prone to design inefficiencies such as choosing obvious permutation. Hence, this cipher is not secured.
 Vigenere Cipher
Vigenere cipher uses a text string as a key. Each alphabet in the key is converted to its numeric value, which is used to shift the alphabets in the plaintext. Since this cipher is designed by tweaking the Caesar cipher to make the cryptosystem more robust. Due to its difficulty level of decryption, it was referred to as the unbreakable cipher.
 Transposition Cipher
In transposition cipher, the order of letters in the plaintext is rearranged to form the ciphertext instead of replacing the actual plaintext letters.
Conclusion
This guide explains indepth what Playfair cipher is, its relevance, advantages, and disadvantages. Further, it demonstrates the encryption and decryption algorithm of Playfair cipher in easytounderstand language, with examples.
Playfair cipher is one of the most ancient and effective methods of data encryption. Further, understanding Playfair cipher is the basic foundation of data encryption and machine learning.
So, have you made up your mind to make a career in Cyber Security? Visit our Master Certificate in Cyber Security (Red Team) for further help. It is the first program in offensive technologies in India and allows learners to practice in a realtime simulated ecosystem, that will give them an edge in this competitive world.
Also Read
PEOPLE ALSO READ

PotpourriJigsaw Academy is the #1 Analytics Training Institute in India

Articles“I Would Recommend This Course To Anyone Who’s Interested In Pursuing Business Analytics” – That’s What Our Learners Say!

ArticlesChannel Your Inner Business Analyst With The Right Upskilling Program

ArticlesAI needs Diversity to reduce Gender and Racial Bias!

ArticlesWhen Is The Best Time To Build A Career In Data Science You Ask? – We Say NOW!