So the first topic that we're going to talk about is confidentiality, encryption and decryption. And of course, this was what was going on at Bletchley Park in World War II. So the terminology that we'll use in this is plain text and ciphertext. And the idea is whether it's text or other information, there is the information that we actually want to transmit whether it's a credit card number or something else. And then there is the encrypted version of that, and we'll call that the ciphertext. And the ciphertext is what we assume is revealed to intermediate parties. Whether they are stopping it, and changing it, or they're just watching it. It's still, the ciphertext is the stuff that we are just by the nature of the communication we are forced to reveal it, or there is a probability that we'll reveal it. So it is hopefully unintelligible, and hopefully it is difficult to go from the ciphertext to the plain text, except if you are the actual intended recipient, or impossible. Encryption is the act of going from plain text to ciphertext. And returning the ciphertext back to the plain text is decryption. And there is a key. Some kind of a key, which is really sort of a, some data plus a technique plus an algorithm that goes back and forth. So there are two kinds of systems that we'll talk about in the upcoming lectures. One is called a secret key, and the other is called a public key. the secret key is the one we talked about at the very beginning. The secret key was really used, from the Romans and Caesar, on up to World War II. the public key encryption really is much more recent, in the 60's and the 70's and we'll talk about that later on. So the first thing we'll talk about is the shared secret, or secret key. the secret key is also called symmetric key, which means that both parties have to be in possession of the same information. You basically use the same key material to encrypt as you do to decrypt. The the public key is asymmetric, which means you use one key to encrypt, and a different key to decrypt. We'll get to that later. and so the problem that secret key has, that led to the need to invent a public key, is the fact that you need to at some point have a secure communication. Whether you're sitting in a room together and you hand each other code books, whatever it is, you have to have a way to distribute the key in a secure manner. The public key, which we'll get to later, has a way of distributing the key in a in a using insecure medium. And you'll see when we get there it's like, so obvious and clever, you wonder why nobody thought of it until you know very recently. So, here is the path. Right? You had some plain-text, you you have say the word candy that you want to send. You're going to encrypt with a shift, where you, you just go to the next later letters, so C becomes D, A becomes B, N becomes O, and so now we have the D, B, O, E, Z. That is the plain text coming from Alice. Alice sends it in the dangerous, dangerous, nasty wide world of you know routers or radio with with Morse code, or whatever it is we're going to do, whatever it is were going to do, where the message might be intercepted by somebody in Eve. Now there not intercepting the plain-text, we assume that this part here is secure, and this part here is secure. It's only dangerous while it's in flight, somehow, in the middle. And we only worry about Eve getting it. And then, then at some point, because Bob has the key which is subtract one, Bob goes from each of the ciphertext letters back to the plain text letters. And voila, out comes the plain-text again. And so, Eve's problem is I'm, Eve is only handed, well no, sorry, sorry. Eve's not, Eve's not given the key, Eve is given the ciphertext and nothing else, and she must, like Bletchley Park, must derive whatever it is. Derive the key, derive the plain-text, whatever it is. That's Eve's goal. The Caesar cipher, is the kind of the oldest, most widely used forms of encryption. It uses the notion of a shift. The shift number is just as I've shown. A shift of 1, means A becomes B and X becomes Y, and L becomes L becomes M. So, you just take and move a fixed position down the al. This was used for a surprisingly long period of time. And there are some pretty good YouTube videos that kind of you can, if you want to see more about sort of the, the how this works and the math behind it, and how you break it. It's, it's pretty fascinating. I mean, finally it's just, it's completely breakable. and we'll actually going to break it here pretty soon, ourselves. So the Caesar Cipher. So I want to pause and let you see a YouTube video, here from a, beloved movie called The Christmas Story, where little Ralphie gets his Little Orphan Annie secret decoder ring. And Little Orphan Annie sends a decoded message, an encoded ciphertext, through the radio. Everyone can hear it, but only those people who have the secret decoder ring can decrypt the message. And you can see that it is a, a Caesar cipher it has a shift. You'll note that the first thing they say before they say the encrypted message in the radio is that you're supposed to connect B and 13, or something like that, and then you rotate the two wheels of the secret decoder ring to the b13. And then you can read across the secret decoder ring and decrypt the message as it's decrypted, and then he slowly decrypts it. And then, of course, there is the delightful moment where he realizes the crash, crass commercialism that that, that are the complete lack of interesting meaning in, in all of this. So, without further ado, let's take a look at Ralphie and A Christmas Story. We'll be right back. So, I hope you liked that, hope you liked that. and so off we go. we're going to have a secret decoder ring for this class. I would love to be able to send you all, oops, come down. I would love to be able to send you all a little mechanical wheel to move the stuff back and forth. But instead I used the internet, and I'm going to send you a PDF, and at this point you might want to pause the video, and grab this PDF. Okay? grab it. Secretdecoder.pdf. Dr-chuck.com/SecretDecoder.pdf. And download it, and you might even want to print it out. Because we're going to, at this moment do a code breaking exercise. Okay? And so let me tell you how to use this secret decoder ring. So the top line here is the plain text. And if you recall Caesar shift has a, a, a shift number. And so to encode, you go from plain-text, let's say I want to do Chuck. Alright, I want to encode Chuck. And I want to encode it with a shift of two. So a shift of two means we select this. And we basically go C is our plain-text, and then down we go E. So then we go E is our first letter. And then H is our second letter, so we go down and that means H becomes J. Yeah, and so U becomes W. So now I'm doing my encryptions. So E H W is the encrypted ciphertext. So, let me clear that, and write back down here. Oop, maybe, a different, different color. E H W. Now to decrypt, remember, you need to know the shift. So, we somehow communicated separately and securely, what the shift was. And so, now we want, we have received our ciphertext. We received our ciphertext, and we need to decrypt it. OK? And so we know that the shift is two, so we go to E, we go in the shift row, and then we go up to the plain text row, and that says the first one is C. Then we go to H, we go to the the encoded text row. And we go back up to the plain text row, and so that's an H. Oh, wait, wait, wait. It's not H W. What am I thinking? This should have been a J. I got this wrong. Sorry about that. So, that's wrong. Here's a J, moves up to the H. Then the W, let's see if I got W right, yeah. So W is my last ciphertext, and it goes up to the U. OK? Dot, dot, dot, dot, dot. So you see the pattern that our in encoding is plain text down to shift position, and our decoding is shift position back up to plain text. OK? And, so this is our secret decoder ring. So go grab it and download it, so that you can participate in the next exercise. So now you are going to be cast in the role of Bletchley Park. OK, ready? So here is your first code breaking exercise. OK. So here we go. So you're Bletchley Park, right? You just intercepted this ciphertext. U B U P B T U. Whoa, it's encrypted. It's clearly meaningless. So, how are you going to be decrypt it? Well, the technique is, take a look, and decrypt it with all the shift numbers. Right? You're going to do this by hand, you're going to be a computer yourself. You're going to do all the shift encrypting, and just like in Bletchley Park, you know you've succeeded when the plain text makes sense. Right when the plain text makes no sense, then you haven't succeeded. But in some point the plain text makes sense. So what you need to do is take your secret decoder ring, and you need to decrypt it with a shift of one, a shift of two, a shift of three, a shift of four, and if you have your family members around, you can put out multiple copies of the secret decoder ring, and you can assign different shifts to different family members. So you have to decrypt this 26 times. Have to decrypt it 26 times. And then you'd look at all the 26 decryptions, and then you decide which one makes the most sense. OK? So, don't peek, decrypt this one. I made it easy on you. OK? So, we'll stop now, and give you a little bit of time to decrypt this one. Don't start pause until you actually have decrypted it. OK? OK, this is your last chance for spoiler alert. So here we are. We're about to decrypt it. Here we go. I did make it easy on you. It was a shift of one. If was a shift of one. If you started at 12, you're kind of foolish. Right? So you started at one, and you go, like, oh great, so now, I'm going to decrypt it. I'll start at one. here's the plain text, this should be PP. That's the plain text. So I'll start with U. If it's one, then I go up, and it's T. And the second one is P, so I go up, and it's O, T O. Keep going, says toast. So you say to yourself, well that's a word, so it must be it. Well hello. What are you doing here? Do you want to say hi to my students? >> Meow. >> This is the cat. This is Eddie cat. He likes to come up into my office, and look. So do you know anything about encryption? Hm? Do you know anything about encryption? So you use a shift of one, and then you go from the encryption text up to the plain text. Meow. OK. You are clearly not interested in my lecture. So that was my cat. Hello, sorry, I can't open a window for you, because I'm doing a lecture. OK. so,[LAUGH] ,[CROSSTALK], you're going like just keep bugging that window, until I kick you out of the room aren't you? So, you're going to have to get kicked out. Out you go. [SOUND] He's was going to keep hitting, keep hitting that, until I opened it for him. OK. So, so now you've broken this code. And again, just like in Bletchley Park, you only knew that you broke it, if it made sense. And and so, luckily the, in Bletchley Park the messages were longer, and they were often looking for canonical things that they would say everyday. So here we go. And and so that's the breaking of that one. And it turns out the shift of one was the thing that we did. So here is your second task. This one's longer, and its not a shift of one. And so, so this is a situation where you would really have to get your whole family going on this. Right? Where you gotta do 26 decryptions of this, and it will, you know, make sense to you. You decrypt it 26 times. Right? And so, this one's going to be harder. I guess you could just, just decrypt one word, but it's just not a shift of one. But now we're going to do another trick. OK? So, I don't want you to try all 26. Because there's, there's a mistake in this. There is a leakage of information, that makes it so that you can, figure out what the right decryption to try it might be. So this is English. This is an English sentence. So stare at it for a while, and find a more optimal way to decrypt it, than trying all 26 shift patterns. OK? So there’s a way to optimize this. A way to cleverly figure out what might be the best shift, or how not to have to decrypt the entire message 26 times, to reduce the complexity. And that's because we've leaked some information here, that should be pretty obvious to you. OK? So, let me give you a moment to break this one. It shouldn't take you too long, and you shouldn't have to force your whole family to decrypt this stuff. OK? So here we go. Give you a chance to decrypt it. OK, this is your last chance before the reveal. You ready? Here we go. So here is the decrypted text. The shift turns out to be 13, it's a shift of 13. And the, the weakness of this whole thing is this, right here. In the English language, what is a single character, we're not encrypting the spaces you'll notice, because the spaces come across. So what is the one single character, word, that we have in the English language, that's capitalized? Well, that's usually I. I need a jet, money and a jet. What is the one thing that we do in the English language that is a single character word that is all lowercase, that's lower case typically, unless it's at the beginning of a sentence? And that is the letter A. So basically, you didn't have to decrypt the whole message. You see some weird pattern, and you go like this. I just have to figure out, and then you go look. And you look in the row 13, the plain text. And you go, like oh. Where's, you go look at the I, because you guessed at plain text. And then you just look down until you see the V. And within seconds, literally, within seconds, if you do it right, within seconds, you know it's a shift of 13. And then it's a trivial matter to convert it. So, you could figure out the shift code within seconds. And these, this was how Bletchley Park figured it out. And this is why the known plain text was so important. Because you'd only have to figure out, like, one letter, if you knew what the plain text was. And often they would know by length, and certain other things. Oh, this is, I, I think we can guess what this plain text was that this particular operator would send. And this has to do with the leakage of information. It's not the, it's not the mathematical perfection, or lack of perfection in the security key. It's some other leak, it's some other thing. When they're going like, oh, wait a sec, I can take advantage of something. It was just equally encrypted as any other message, but because I gave you this clue, of an uppercase single character word and a lower case single character word. Upper, lower case single character word and upper case single character word, I greatly reduced the amount of effort that you had to put in. OK? Now, what's cool about this, you can go to this website, www.rot13.com, is that, long ago, before Facebook and before Twitter and before all these things we had these things called newsgroups. And they were kind of this weird kind of, collective email list that we had. And this was, like, in the 80's. And it was even used in storing forward networks. Where, it was kind of like Facebook in storing forward networks. Meaning that it might take four hours for you to see the status update. But we kind of of would subscribe to these collective things. And there was one that was basically the dirty jokes. And the thing about dirty jokes was, part of the, part of what we were trying to do in this thing, was, you weren't supposed to swear. And there was software that would filter out swear words. from, if, if you put a swear word in to a dirty joke it would not forward the message. And so we had to have a way to encrypt messages that included swear words. So that we could tell dirty jokes to each other, for those who wanted to subscribe to the dirty joke list. And so they came up with this rote 13. So we came up with a simple Caesar cipher, with a shift of 13. 13 beautifully, of course, is 26 divided by 2. So it's a symmetric shift. The shifting in by 13, is the same as shifting out. So, of all the Caesar's ciphers, a shift of 13, the encryption and the decryption are exactly the same calculation. And so we would we would type our dirty joke into, rot13, and convert it to rot13, and we would send it in rot13. And then we would, if we wanted to decrypt it. But what became funny after a while, was, we were so used to reading rot13, that it almost became like a second language. Right? We could, we could read second, we could start reading the dirty jokes in rot13, and we would laugh before we translated them up. So rot13, has an interesting sort of historical thing. And you can go to rot13 and sort of like encrypt, whatever you want to say. And I'll probably have some questions to ask you, where you will have to do some rot13 encryption. And so that's the end of this lecture, where we talk about Caesar ciphers and the various techniques, and how Caesar ciphers work. And, so we'll be back and talk about cryptographic hashes.