 So let's introduce some more basic terminology. Cryptosystems are separated into two broad categories. Given a message, we can encrypt it using a stream cipher which encrypts each unit as it's presented. For example, if we're encrypting a message, then our stream cipher would encrypt each letter as it comes to it. Or we can talk about a block cipher which encrypts a block of units waiting to proceed until it has the entire block. So again if we're encrypting a message, maybe we'll take a block of five letters and encrypt it all at once. But mathematically there's no important difference between the two. A stream cipher is a block cipher where the block length is one, or a block cipher is a stream cipher where the unit is a block of characters. More importantly, we can classify cryptosystems as substitution ciphers which replace units of the message with encrypted units, and transposition ciphers which rearrange units of the message. So for a substitution cipher, we replace a unit of the message with an encrypted version of the unit. So we might replace letters with letters, numbers with numbers, images with images, code phrases with code phrases. Or we can mix and match. We could replace letters with images, or phrases with letters, or images with phrases. And this leads to a problem, how do we keep the substitution straight? And one way we can do that is to use a code book. A substitution table is a simple code book. So for example, let's encrypt the message Hello World using the substitution table. And let's also decrypt the message. So using our substitution table, we see that the plain text H is replaced with the cipher text A. The plain text E is replaced with the cipher text Y. And our other letters are correspondingly replaced. Meanwhile, if we have this cipher text, the cipher text U must have come from the plain text M. The cipher text B must have come from the plain text A. The cipher text W had to come from the plain text T. And so on for the rest of our letters, giving us the decrypted message. In a transposition cipher, the units of the message are rearranged in some pattern. Now it's convenient to think about taking a block of our message. And what we're going to do is we're going to rearrange things. We can represent this using permutation notation. And we'll do that by throwing a set of parentheses around it. And the way to read this is that the new first character used to be in the third place, the new second character used to be in the first place, the new third character used to be in the fourth place, and so on. So for example, if I wanted to use this transposition to encrypt hello world, the first thing to recognize is we need to break our message up into a couple of blocks and apply the transposition to each block. So H was in the one place, so now it's here. E was in the two place, now it's here at the end. The first L in the three place now is at the beginning. The second L in the four place is now here. And the L, which was at the end, is now here. And we make a similar arrangement for the second word. And so now we're able to introduce two more ideas known as confusion and diffusion. A cryptosystem conceals the message through two primary mechanisms. Confusion, which obscures the identity of the message units. So for example, substitution ciphers provide confusion. The other important part of a cryptosystem is diffusion, which obscures the relationship between the message units. And transposition ciphers provide diffusion. And this leads to the first truly important concept. Cryptosystems that rely only on confusion can be attacked by analyzing the relationship between the message units. Meanwhile, cryptosystems that rely only on diffusion can be attacked by analyzing the individual units of the message. And what that means is that strong cryptosystems use both confusion and diffusion. So for example, let's apply both a substitution and a transposition, which we'll write in permutation notation. So first we'll apply our substitution. So our message, FORTRAN FOREVER, we can replace F with T, O with I, R with O, and so on. And next we apply our permutation. Now since our permutation is on four elements, we'll break our message up into four element blocks. Since the last block is short, we'll add some random letters to complete it. This is known as padding the message. And so now we'll apply our transposition. So in the first block, our one is a T, our two is an I, our three is an O, and our four is a W. Rearranging these in the order 4, 1, 3, 2 gives us. We'll rearrange the letters in the second block, in the third, and in the fourth. And so applying the permutation gives us our encrypted value.