×

# Playfair Cipher in Cryptography

In this tutorial, we will learn about the Playfair Cipher technique which is also a substitutional cipher technique. We will learn what procedure it follows for encryption of the text, and will also see how the encryption is performed? By Monika Sharma Last updated : May 24, 2023

## What is Playfair Cipher in Cryptography?

Playfair cipher is also a substitution cipher technique but it is a bit different than other substitution cipher techniques. Its rules are different. In this cipher, we already know the plain text and the keyword. In this technique, we have to construct a matrix of 5x5 and we have to put each letter of the keyword in that matrix. We should start with the first block of the matrix and fill it horizontally. When the keyword is filled in that matrix then put all the other remaining alphabets in that matrix. The 5x5 matrix is the base structure of this technique. Total blocks in the matrix are 25 and there are 26 alphabets so we have to put 'i' and 'j' in the same block.

## Playfair Cipher Implementation

So, to implement the Playfair cipher technique, we have to break the plain text in the pair of 2 letters each.

1. If the number of alphabets in the message is even then making the pair of 2 letters each.
2. If the number of alphabets in the message is odd then take an extra 'x' with the last letter of the plain text.
3. In the pair, if we are getting 2 same alphabets then take 'x' with both the alphabets to make pair.

## Finding the Cipher Text

So now we have the plain text broken into pairs of 2 letters each. We have to find that 2 letters in the table individually. Every letter will have a cipher letter for it. The method for finding the Cipher Text is given below,

1. If both the letters are in the same column then the ciphertext for both the letters will be the letter just below that letter and if the plain text letter in on the end of the column then the cipher letter for that letter is the first letter of that column.
2. If both the letters are in the same row then the ciphertext for both the letters will be the letter just right to that letter and if the plain text letter in on the end of the row then the cipher letter for that letter is the first letter of that row.
3. If the plain text letters are neither in the same column nor in the same row then we’ll make a rectangle using the 2 blocks of 2 plain text letters. And in this way, we have 2 more blocks in the rectangle. Now we will take the first letter of the plain text and we’ll traverse its row and the endpoint (another vertex of the rectangle) will be the ciphertext for that letter. Now we’ll take the 2nd letter of plain text and we’ll traverse its row and the endpoint (another vertex of the rectangle) will be the ciphertext letter for that plain text. (We always have to traverse the rows in this case.)

In this way, we can implement the Playfair Cipher technique.

Comments and Discussions!

Student's Section
Subscribe

Copyright © 2024 www.includehelp.com. All rights reserved.