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 cypher offers data encryption and decryption to ensure data privacy. This guide explains everything about the Playfair cypher, its advantages and disadvantages, its relevance, and the Playfair encryption and decryption algorithms with examples.
In this article, let us look at the following:
Playfair cipher is the first and best-known 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 non-critical secrets during actual combat. By the time the enemy cryptanalysts could decrypt the information, it was useless to them.
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 cypher was no longer used, as the computers can solve Playfair cyphers in a few seconds using break codes. Due to this reason, with the advancement of digital encryption and the passage of time, the Playfair cypher was no more an acceptable form of encoding messages, as there was a risk of data getting into the wrong hands. Thus, the Playfair cypher cannot be recommended for business organizations. Further, it’s a manual and labor-centric process that does not need any Playfair cypher calculator or decoder. However, there are Playfair cypher programs in C and Python.
We will have a look at some examples of Playfair Cipher with encryption and decryption algorithms.
The Playfair cypher has a key and 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.
The Playfair cipher encryption algorithm has two steps.
Before encrypting the text, you must 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.’
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 considered 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 the alphabet a-z 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 |
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
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 opposite horizontal corners, 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”
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.
Generate the key square using the key texts and follow the same rules mentioned in this example’s “Step 1 – Creating the key square” section.
The text that we want to decrypt is “lfgdnwdpwocv.” After splitting it into digraphs, it will look like
LF GD NW DP WO CV
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.”
With its basic features, there are specific advantages and disadvantages of Playfair cipher.
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 cypher doesn’t work with the Playfair cypher, 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.
The encrypting and decrypting data in Playfair cypher is a manual method that eliminates the need for a Playfair cypher calculator. Without using a Playfair cypher decoder, information can securely travel between its source and destination without getting into the wrong hands when you implement Playfair cypher encryption-decryption in C.
The Playfair cipher is a symmetric cipher, so 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.
One primary disadvantage of Playfair cipher is that you can’t use it to transmit massive data.
In the Playfair cipher, the substitution is self-inverse. 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 plaintext language.
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.
Also referred to as the Shift cipher, the Caesar cipher is the simplest type of substitution cipher scheme. Using this cipher, one can form a ciphertext by substituting each alphabet of plaintext with 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.
This cipher utilizes some permutations of the letters in the alphabet. With 26 letters, the sender and receiver may select any of the 26! which is a 4 x 10^{26} possible permutation as a ciphertext alphabet, which is the scheme’s secret key. 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 permutations. Hence, this cipher is not secured.
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 alphabet in plaintext. Since this cipher is designed by tweaking the Caesar cipher to make the cryptosystem more robust, it was referred to as the unbreakable cipher due to its difficulty level of decryption.
In transposition cipher, the order of letters in the plaintext is rearranged to form the ciphertext instead of replacing the actual plaintext letters.
This guide explains in-depth what Playfair cipher is, its relevance, advantages, and disadvantages. Further, with examples, it demonstrates the encryption and decryption algorithm of Playfair cipher in easy-to-understand language. Playfair cipher is one of the most ancient and effective data encryption methods. Further, understanding Playfair cipher is the basic foundation of data encryption and machine learning.
If you are looking to upskill in emerging technologies like Cybersecurity and looking out for a comprehensive course, then you have arrived at the correct place. Check out the array of programs offered by UNext to those interested learners to enable them to upskill and take complete advantage of the ocean of opportunities in these domains.