Transcript for:
Understanding the Playfair Cipher Basics

Hello everyone, welcome back. In this presentation we will focus on Playfair Cypher part 1. Let's dive into the outcomes first. Upon the completion of the session the learner will be able to, outcome number 1, we will understand the basic working of Playfair Cypher and outcome number 2, we will know about diagrams and the generation of diagrams with and without filler character. Before stepping into Playfair cipher, let's see the classical encryption techniques.

We know basically there are two techniques under classical encryption techniques. Number one, the substitution technique and number two, transposition technique. We are now in the substitution technique and we are going to see about the Playfair cipher in this presentation.

Why waiting? Let's directly step into the topic of the day, the Playfair cipher. This Playfair cipher is also known as Playfair Squire or Wheatstone Playfair Cipher. And what type of ciphering technique is this?

It is a manual symmetric encryption technique. What is symmetric encryption? The same key is used for both encryption and decryption. Suppose if the sender or the source is creating a cipher text and obviously this source or sender will be using a key. If the same key is used by the receiver also in order to decrypt the message to get the plain text back, then this is symmetric encryption.

Simply both sender and receiver uses the same key for encryption and decryption. And this playfair cipher is also a symmetric encryption technique. And this playfair cipher is the first literal diagram substitution technique. Please note here, this is going to use an approach called diagrams and this is the first literal diagram substitution approach.

I know you will think about this word diagrams. Don't worry about this now, anyway we are going to see that shortly. And this Playfair technique was invented in 1854 by Charles Wheatstone.

Now, you may be wondering, when Charles Wheatstone has invented this approach, why this name Playfair then? Actually, this technique bore the name of Lord Playfair for promoting its use. That's the basic theoretical aspects of Playfair.

Let's dive into the working of Playfair. Basically, this Playfair ciphering technique is a multiple letter encryption technique. So here, This is not a single letter encryption technique where this is a multiple letter encryption technique. Let's take the previous encryption techniques, maybe the Caesar cipher or the shift cipher or mono-alphabetic cipher. Say if A is replaced as M for example, wherever A is appearing in the plain text, then M will be the ciphertext character throughout the message, throughout the encryption.

Let's take another example. Suppose if the plain text letter D is encrypted as Z, throughout the message, wherever the plaintext letter D appears, Z will be the ciphertext letter. Whereas, in this playfair cipher, suppose if the plaintext letter D is replaced as M, for the next occurrence of D, it may not be M.

It will be N or it will be a different character. So, obviously, this will be confusing the attacker, right? In one occurrence, D is replaced as M. In another occurrence, D is replaced as X.

In another occurrence, D can be replaced as a new character also or a new letter also. So, this is actually the multiletter encryption technique and which improves the security when compared to the Caesar cipher, shift ciphers and the mono-alphabetic ciphers as well. And as I mentioned, this is going to follow the diagrams approach.

So, where the plain text letters are going to be splitted into diagrams. I will explain that now. Obviously, any cryptographic technique or any encryption-decryption technique will require a key.

So, this Playfair cipher also require a key and the key is the keyword. So basically, this Playfair ciphering technique is going to use a keyword as the key. For example, monarchy is the key that I have taken here.

This keyword or this key can be anything, any English word or any sentence also. But make sure that we are going to use a 5 x 5 matrix and this 5 x 5 matrix is going to be constructed using the keyword that we have taken as the key. Let's see that now.

So obviously as mentioned, we are going to take a 5 x 5 matrix. and this 5 cross 5 matrix is going to be filled up with the keyword. In this example, we have taken the keyword as monarchy, right? Do we have any repeating character here? M is appearing only once in the keyword, O is also appearing only once in the keyword and we can witness that all other letters are also appearing exactly once in the keyword.

So, we are going to fill the 5 cross 5 matrix like this. First, M is filled, O, N, A, R, C, H, Y. In case, if there is a repeating letter in the keyword, for example, if O is appearing one more time here, we should not fill that O. Say for example, if the keyword is monarchy O, then we should not fill O here.

Already the letter O is filled, right? So, we need to fill the alphabet only once in the 5 cross 5 matrix that we are going to maintain. If the keyword has repeating letters, just ignore those repeating letters while filling up the 5 x 5 matrix for the second time and the later occurrence. So, only once it should be there.

Now, we are done with filling up the keyword in the 5 x 5 matrix. Now, we need to start filling up the other alphabets. Let's start with the alphabet A, but A is already there in the keyword, so we should not fill A here. Then we should start with B, right? So, the next character that is going to be filled in the 5 x 5 matrix is B.

Then C, no, C is already there in the keyword. So, we should not fill it, isn't it? So, C is already there. So, I am just ignoring C. Then D, since D is not there in the keyword, I am filling D.

Then E, F, G, H, no, H is already there in the keyword. Then I, can you see here, I am combining I and J together. I will explain you why. Always remember in the Playfair ciphering technique, I am combining I, J together.

And then K. L, M is already there in the keyword, so ignoring M. N, I'm ignoring N also because N is also there in the keyword. O is also there in the keyword.

P, Q, R is also there in the keyword. S, T, U, V, W, X, Y is there in the keyword and Z. So we have completely filling up the characters. Now I'll explain why I and J are combined together.

We know it is a 5 x 5 matrix, so a total of 25 alphabets can be accommodated in this box or in this 5 x 5 matrix, isn't it? But in English, we have 26 alphabets. How to fill 26 alphabets in 25 cells?

It's not possible because we need to have only one alphabet in one cell, isn't it? So, in this case, we are combining i and j together. In case, if the character i and j are appearing in the keyword, just use it only once in the 5 x 5 matrix.

So, we are done dealing with the 5 cross 5 matrix that is constructed using a keyword. In this example, we have taken the keyword monarchy. Now, we can go for the encryption technique. For encryption, we need a plain text, right?

So, we can take a plain text. Before we can see the encryption technique, we should know the rules for doing this encryption. Let's now see the rules for encryption.

The first rule as far as this encryption is concerned using this Playfair cipher is creating the diagrams. So basically, if you have a plain text, Just create diagrams for it. I will explain creating diagrams in the next slide. After creating the diagrams, say if we have repeating letters in the diagrams and we need to insert the filler character. So rule number two also I will explain in the next slide.

Then after that, we are going for encryption. After creating the diagram, if we see both the characters are there in the same column of the 5 cross 5 matrix, then we need to go down. This is the logic we are going to apply. In case if we are already at the bottom, we need to wrap around. In case if the both the letters of the diagrams are appearing in the same row, then we need to move right.

If we are already at the end of the 5 x 5 matrix, then we need to wrap around. And finally, the letters in the diagram can be appearing as a rectangle in different row, different column, then we need to swap. I can very well understand that these rules will not be clear for you. Anyway, I will explain that when we see an example.

In a nutshell, After creating the diagrams, if we see there is a repeating letter in the diagrams, we are going to use a filler letter. Say for example, if the plaintext is hello, H E L L O. So obviously, H E will be the diagram, the first diagram. We are splitting it into two letters, right. So where is H?

Can you see? H is here. Where is E?

E is here. Now, H is in a different row, E is in a different row, isn't it? We can find H, E are not in the same column as well as in the same row.

Whereas, H, E are in different row, different column. So, we can say it is the rectangle approach. So, this is forming a rectangle or a square, isn't it?

So, in this example, H, E is matching for rule number 5. Then, we need to do swap operation. Don't worry about this now. In this lecture, I am going to present only the rules and the basics of PlayFileCypher. Before we sign out, let's see the diagrams. Let's take the example.

In this example, we are going to encrypt the playing text attack. I am not going to explain the encryption technique here. But I'm going to explain how diagrams are created.

So ATTACK, this is the plaintext. So we need to create diagrams as per rule number one, isn't it? So the diagrams are AT, TA, CK.

So this plaintext is splitted into two letters like this, AT, then TA, then CK. Do we have any repeating characters here? So in one diagram, in this diagram, we don't have repeating characters.

A is a different alphabet, T is a different alphabet. Here also they are different, here also they are different. Let's see another example.

The playing text is Neso Academy and we are going to create the diagrams as N E S O A C A D E, M and the last letter is Y. If you have Y alone, it's not a diagram. So, if the last letter of the playing text is not a diagram, it is left alone. So, insert a filler character X so that this also becomes a diagram. While decryption, we can remove this letter.

We will see another example also. In this example, the playing text is balloon. Now, how it is going to be splitted? B, A, L, L, O, O, N. Now if you observe here, do we have repeating letters here?

No, but what about here? Yes, we have same letters appearing twice in the same diagram. So we need to insert a filler character x, so that this ll becomes lxl, isn't it? Just see here, so ba is retained as such.

This ll is modified as, we are just going to insert the filler character x here. So ll becomes lx Then this L is going to join to the next diagram L. Then this O is joined here. Then O N is appearing like this. After the insertion of this filler character X, it resolved three problems.

One is, it has resolved the repeating letters here. Also the repeating letters here. We are not going to use another filler letter X for this.

Already the insertion of this filler letter has solved this problem. Isn't it? Then this N was left alone in the previous case. But because of this insertion of this filler character x, this n has got a company and the companion is o.

So, we got o n, it is now complete. We should always keep one thing in mind, because of inserting a filler character, a new repeating letter may be formed in the other diagrams. So, that also should be broken by inserting a filler character.

As long as you see repeating letters, always remove those repeating letters in the diagrams by inserting the filler character. After inserting the filler character, if you are finding that the last letter is left alone and it is odd. Just add x to the last letter so that that also becomes a diagram.

So that's it about rule number one and rule number two. Rule number one that is creating the diagrams and if we find repeating letters we can use filler character. In this example we have taken the filler character as x where this filler character is decided by both sender and the receiver together. And that's it guys. I hope now you understood the basic working of Playfair cipher.

and we also have known about what is a diagram and how to generate diagrams with and without filler character. In the next presentation, we will see how to do encryption using Playfair cipher. I hope you guys enjoyed this presentation and thank you for watching.