In this lecture, we're going to develop algorithms for cybersecurity. So we're going to develop both encryption algorithm and the decryption algorithm so we can secure our messages from prying eyes. For the encryption problem, we'll develop an algorithm that implements the Caesar Cipher with a right shift of five. So the Caesar Cipher is named after Julius Caesar, and the approach is a simple character substitution approach. So we just replace each character in our message with a different character. We'll see with the decryption, we have to know how to get back the other way. We'll implement both of those, but we'll start with the encryption algorithm. So here is our starting point, and we're going to develop an algorithm to explain to somebody how to do this. So we have a list on the top line of the characters in plain text, if you will. So these are just the characters of the alphabet. We're not going to include punctuation, or lowercase characters, or even spaces. We're just going to include the 26 characters in the alphabet. The line below it is the Cipher characters when we're doing a right shift of five for the Caesar Cipher. So obviously, these characters would be different if we were doing a right shift of seven or a left shift of three, but we're just solving the problem of doing right shift five for the Caesar Cipher. Of course, our algorithm would be generalizable if we added some additional steps that took care of shifts in other directions by other amount. So we're doing this manually. Well, actually, by the time the course is done, once we know enough C programming, we'll implement this in a C program as well. But because we're doing it manually, this is convenient to have the plain line of characters and the Cipher line of characters. So we will include those in our algorithm. In fact, let's start working on that algorithm now. As you can see, our algorithm is a blank page at this point. So let's give somebody instructions all the way through for encrypting a message using a right shift of five Caesar Cipher. So step one, we'll actually number the steps because that is helpful to a lot of people. Step one, we'll say label a line Plain and list the characters, A to Z, in order, on that line. So that generates this plain line that we've shown. Now we need to generate the Cipher line. We will do this in two pieces. We'll have them do this part first, and then we'll add the rest. We can certainly say something like rotate by five or something like that to the left to actually get the cipher line. But, we'll give some pretty precise detailed instructions for how to do this. So back in our algorithm. Step two will be label a line Cipher and list the characters, F through Z, in order, on that line, lining up each character with a character on the Plain line. You'll notice that it's useful for us to label these lines, the plain line and the cipher line, so that we can easily refer to lines by name rather than by this line, or the other line, or something like that. So it's often the case that we like to name things to make it easier for us to provide detailed instructions. So we have now done the first part. We've done this part. Now let's add this part, A through E. So list the characters, A through E, at the end of the Cipher line, lining them up with the characters. Go back and check because I forgot. V. So lining them up with the characters, V through Z, on the Plain line. Now, you'll notice that I've started using inconsistent terminology. Here I put A to Z, here I put F through Z, and so on. Since I inadvertently used through for most of these, let's change this to say through as well, or something like through to make it say through as well. So these first three steps are just about getting the Plain and Cipher lines set up to make it easier for us to manually encrypt a message. Now, let's add a step that will actually encrypt a message. So generate a message in plain text using only the letter characters in the Plain line. That way, they don't use exclamation points, or spaces, or other punctuation to try to build their message, and then they'll have trouble, of course, when they tried to encrypt it. Last step is to replace each character in the plain text message with the character on the Cipher line below the corresponding character on the Plain line. So it's a little confusing to say corresponding character, corresponding to what? So let's actually say below the character in the plain text message on the Plain line. Okay. Hopefully, that is sufficiently detailed. So we will now go back and encrypt our message. Our message is the clash. If you've never heard of the clash, you should google it or something to find out about the clash. So here's what we do. The first character in plain text is T. So we find that character on the Plain line and replace it with the character below it. So T gets replaced by Y, H gets replaced by M, E gets replaced by J, C gets replaced by H, L by Q, A by F, S by X, and H by M, of course. So we have now followed our algorithm to encrypt the message with a Caesar Cipher using a right shift of five. Now that we have an encrypted message, we need to develop the algorithm to decrypt the message. So our decryption problem is, develop an algorithm to decrypt a message that has been encrypted using the Caesar Cipher right shift five. Like before, it is easier to have the Cipher characters on the line, and the plain characters on the line below it so that we can actually just do the substitution easily, since we're doing it manually here. So let's grab some of these lines and take advantage of the work we've already done. Now, we're going to label this line Cipher. So we're going to find it a little more useful to use the sequence of steps we included in step three here. So let's get rid of that one, although we do want to label a line Plain. This time, go back to what it should look like. So basically, what we're doing is we're shifting back the other way here. So first, we'll take care of this part. So we'll do V through Z. We're going to list the characters V through Z, at the beginning of the Plain line, lining them up with the characters A through E on the Cipher line. Now, let's grab this step three. After all, that would have been handy to have kept it down here. So now, we list the characters A through, we better go check and make sure we know, A through U, at the end of the Plain line, lining them up with the characters F through Z on the Cipher line. We're actually using a technique that you might find useful as you develop algorithms throughout your life. We're taking an algorithm we already created, and saying, "Wow. This is really similar. Let's grab the overall structure of that original algorithm and change the details as necessary to solve the problem we're trying to solve." So that is a standard thing. As you solve more problems, you have the solutions to those problems in your toolbox of solutions. So finding the right tool in that toolbox and reusing it, rather than starting to build it from scratch again, is a standard technique we use all the time, both as normal human beings and also as programmers, you'll find that you'll also use this with programming problems as well. So we have the building the manual lines. Now we just have to do the decryption, and that is very similar to the encryption. So we will replace each character in the cipher text message with the character on the Plain line, below the character in the cipher text message on the Cipher line. So again, we're taking the top character and replacing it with the bottom character here. So the first character in our decrypted plain text is T. Find M, at its H. We find J, it's E. I know what this message should be, so I just want to type clash here, but we better make sure it actually all works. So we find H, and it's C. We find Q, and it's L. We find F, it's A. X is S, and M is H. To recap, in this lecture, we built our most technical algorithms that we've built so far, and they were to encrypt the message using the Caesar Cipher right shift five, and to decrypt a message using the Caesar Cipher right shift five.