 In this lesson, we're going to be looking at a new cipher, the ADF-GVX cipher, which is not a block cipher, but does exhibit some of the same criteria that we know will make a block cipher secure. So let's take a look at some of the properties it does have. So again, this is not a block cipher, but it does exhibit confusion. Each character of our plain text when we use the cipher will undergo substitution using a key to help us create the cipher text. That's nothing new. We've seen confusion all along in this course. It's only been recently that we started calling it that. It introduces something new, which is called fractionation. Each character of our plain text will become two characters in the cipher text, and then those two characters are going to be split apart from each other, and they'll be moved around in the cipher text through a process called transposition. If you think back to the very beginning of this course, we did some transposition ciphers like railfence. And there is going to be some diffusion when we use this cipher. Those two paired cipher text characters, they are going to get spread out through different parts of the message in the final cipher text message once that transposition occurs. And that's what we talked about with diffusion. We want there to be one change now of our plain text character will cause two characters to change in the cipher text, and they're going to be in slightly different places. Now, does that meet that criteria or that goal that we set out for block ciphers that one symbol change will result in over half of them? No. But we'll see this is still a step in the right direction, which is why we're using this cipher before we get into a full blown block cipher. So let's take a look at the encryption process. We'll take our plain text message here, which is math and the numeral four and then the word life, so math for life, of course. And we'll see the key here when we use this cipher is not a letter or a number or a word, but rather a table of information. This table is called a polybius square. You notice it's a capital piece is named after somebody who invented this, but it's a six by six square where each of the rows in the columns are labeled with a character A, D, F, G, V, X and in the field or the inside of that table is filled up with the 26 English characters and the 10 numerals zero through nine. So we can actually encrypt messages that have both the letters and the numbers using this system. Now how you fill this table is unique to you and your messages that you're sending. You might kind of read between the lines of this one from that top row in gray SC one three is kind of like an I and an E and then and it looks like kind of like science and math are the first two words, but then the rest are just kind of jumbled up. You can use some words to try and make this easier to remember, but in practice, you're just going to have to have a copy of this key table when you use your messages. So let's first do the first step of this algorithm or confusion part. Let's make some substitutions. We'll take each character of our plain text message and we're going to look up the two characters that it will be replaced with. So the first character in the plain text or M gets replaced by D a now why D a if we look over to the table, the character M in the green box there is in the row that has the label letter D and the column that's labeled with the letter a. So M gets replaced with D a letter a we find that that's in the row labeled F with the column X and so on down the line. Each of our characters is now replaced with two. Keep in mind that we're always going to put the row character first, then the column label, we could have done it the other way that's somewhat of an arbitrary choice, but we need to have consistency on both the encryption and the decryption process. So row, then label this kind of trying to commit that one. The memory row, then label it's the way I said row and then column. It's the way we always have been doing things when we deal with these multiple numbers and rows and columns. So now we've got this intermediate message. This is not the ciphertext. We can call this maybe the substitution text, but we're going to have to do a little bit of shuffling around of these characters to get that diffusion characteristic that we want and also that fractionation and it'll help us create the ciphertext. So let's walk through that process. In order to do that, we're going to have to use us another piece of secret information, our key word. So not only do we have that table, the Polybius square, that's our key for the substitution. We now need a new key, a key word to help with the transposition part. So it needs to be a word of your choosing. It could be as long, as short as you like. The only characteristic is that you can't have any repeated letters in it. So I've used time, T-I-M-E, each character, each letter only shows up once within the message and we'll see why that's important in just a moment. We're going to create a new kind of table of information here with the labels across the top, one label for each of the characters in your keyword. So I'm going to have four columns here in a moment. Each column will be labeled with a T and then an I and so on. We're going to fill in each row one at a time using those texts from our substitution word. So D-A-F-X for the first four characters, those go in the first row, and then so on down the line. We're going to have a couple empty spaces there at the end and that's okay. We'll see that that does not affect anything at all. Next up, we're going to now shuffle those columns by alphabetizing them. So column E should go up front, followed by I and then M and then T. So now we've reordered those columns and to create our ciphertext, we're now going to read off one column at a time. So it's going to go X-G-D-F and then A-F-D-D-X, F-D-V-X, and then D-D-D-G-A to give us our final ciphertext message. So let's take a look at those characteristics that we said that this has, Fractionation and Diffusion, and let's just kind of see how much of each they might have. So here's our plaintext math for life. We're going to focus on that character for in the plaintext, which goes to these characters in the ciphertext D and then D. If we were to have changed that to the numeral five in the plaintext, we would have had two completely different characters in the ciphertext. So we can verify here that that one character change does in fact make two characters change in the ciphertext. And we mentioned this earlier, we haven't met the goal for a block cipher diffusion where one character change in the plaintext causes half of the characters in the ciphertext to change. But this is the first time that we're seeing that a single character change in the plaintext will have multiple character changes in our ciphertext. So it's worth pointing out. It does do better than the stream ciphers that we've seen so far. It doesn't do as well as the block ciphers that we'll see in the coming lessons. Now let's look at decryption. Now all of the operations that we've done so far, we can just simply undo in the reverse order. So we've got this information here. We've got a new ciphertext. So this is not the ciphertext that we just saw. We've got a new key table here on the bottom left and a new keyword privacy. So let's see how we can take all this information to decipher the ciphertext and get back our plaintext. So if you think about the last thing that we did when we were encoding the message was kind of reading off the columns from our alphabetized table. So let's take a look at our ciphertext and let's focus on using that keyword to create those tables that we can now reorder. Notice our ciphertext has 28 letters. And if we were to write out that table that we expect to see at some point where it has privacy written across the top for the labels, knowing that that has seven columns to it and we have 28 total letters, we know that we can construct four rows that can contain all of those characters. Just take the total number of letters, divide by the number of columns to get the number of rows. Now what we can do now is alphabetize those to create kind of an empty four by seven grid for us to fill up. And if we think back, well, how is this ciphertext created? It was created by reading off the columns of this alphabetized table. So we'll take those first four characters, fill them down DGDD, and then keep going down just the columns to complete this alphabetized table. And now we can now copy those columns over into the correct location to fill up our label table that has the keyword privacy across the top. And now if you think about, well, how did we fill up this table? It came from the substitution text, not the plain text, but the substitution text going across the rows, which means we can now pull it off row by row to create the substitution text. The first row ADDDDDA becomes the first seven characters in the substitution text. And we can do that for the entire table to get the 28 characters that are in our substitution text. Now remember, that's not the plain text, you can probably see that by looking at the characters. But we should now be able to take this text, substitute out the pairs for a single character of plain text using the key. So let's do that. Here's our substitution text. Here's the key that we have for this particular problem. We'll take our substitution text in pairs. And now we can look up AD row column in order to figure out the plain text character A. Remember, we use AD, A is the row label, D is the column label, the plain text is in the field of the table, meaning in the interior of the table. So A and D point to the character A inside, and then the row D, column D point to the character T, and so on. Now how secure is this? It was first crypt analyzed by the French Army Lieutenant George Penvin, and the cipher was broken in early June 1918. This was a World War I cipher, and it was used in the field. You can probably see it was pretty quick to do with just some paper and pencil. You didn't need any crazy computing power to do this. His solution for cracking this message relied on finding some messages with stereotyped beginnings, meaning kind of reused plain text. So he used a known plain text attack to do this, or at least similarly structured plain text to do this. He would look for patterns in the positions that would result in the cipher text that corresponded back to the column headings in that transposition table. So just looking for a lot of patterns. He was really only able to do this well when he was able to get a lot of messages at the same time that were using the same key. So we say there's a very high traffic rate, which usually was okay because when there's a lot of messages being sent at the same time, that's often when the most important messages are being sent because there's some action going on in the battlefield. And it turns out that it was his analysis techniques that allowed the French Army to discover where an attack was being planned, and they're able to reposition troops and hold off that attack. And many people actually think that it ended the war a little bit early as a result. Now, this army lieutenant here became very ill due to all of the time that he was spending trying to crack this message. A lot of people think that his contribution here to break the message took some years off of his life, and he actually died shortly after he was able to crack this message. So that's the ADF GVX cipher. Again, this is not a block cipher, but it's the first cipher that we're seeing past our stream ciphers that are showing both the characteristics of confusion and diffusion, even though they're not as well established as we'll see in future block ciphers. But it's a nice stepping stone to where we're going next, which is a full on block cipher. You should be able to at this point in the lesson be able to encrypt and decrypt messages using this cipher. And hopefully understand what we'll be looking for when we see our block ciphers in our next lesson.