# Cryptography Basics

**A free video tutorial from**Total Seminars â€¢ 750,000+ Enrollments

Home of Mike Meyers and his Team of IT Certification Pros

4.7 instructor rating â€¢
36 courses â€¢
401,029 students

## Lecture description

In this episode, Mike goes over the goals and methods used in cryptography.

### Learn more from the full course

TOTAL: CompTIA Security+ Certification (SY0-501)Everything you need to pass the CompTIA Security+ SY0-501 Exam, from Mike Meyers. CompTIA expert and bestselling author.

18:57:24 of on-demand video â€¢ Updated March 2021

- This is a comprehensive CompTIA Security+ Certification (SY0-501) course. It is designed to prepare you to be able to take and pass the CompTIA Security+exam
- Once you complete the course, you will have the knowledge and confidence to pass the CompTIA exam AND the skills to be a great IT security tech.
- Your new skills and the CompTIA Security+ Cert will help you land a great IT security tech job. Or, get that raise or advancement you are after.
- This course is ideal as both an exam study tool and an on-the-job reference.

English [Auto]
Of any episode that I do in this entire series, this is my favorite because this, my friends, is cryptography. Cryptography is the science, the study of taking data and making it hidden in some way so that other people can't see it and then bringing the data back. So the big word we want to use when we talk about cryptography is taking some kind of information and providing confidentiality to that. Now, we do this through a number of different ways. But the magic word I want to use right now is abuse and obfuscation is to take something that looks like it makes sense and to hide it so that it does not make sense to the casual outside observer. Now, there's a lot of different ways we can do obfuscation to provide confidentiality. One of the things we can do is diffusion. So here here's a picture of my grandson right here. Let's take a look at that. That's Steve. And then he gorgeous. So what I'm going to do is I'm going to diffuse this image and make it fuzzier. Now, in this particular case, we didn't diffuse it too much. So if you look at it, you could probably tell there's still a cute little kid there. And he is cute, but diffusion only allows us to make it less visible, less obvious. Now, what we can also do is confusion. So let's take that same image of Steve one more time and just stir it up. Let's just make a mess out of it. Now, in this particular case, we've created a lot of confusion of the image it's basically stirred up and it would be very difficult for somebody to simply look at this and go, oh, that must be Mike's grandson, Steven. So the other challenge we have with cryptography is we go through this process of taking some kind of data and we go through this obfuscation process. But and here's the important one, is that we've then got to take this obfuscated data and some way bring it back into its original form. So we call this encryption and decryption and cryptography is the process of making this happen. Cryptography has been around for a long, long time. In fact, probably one of the oldest type of cryptography is ever been around is something called the SESAR cipher. I don't know about you, but when I was a little kid and I was eating a box of cereal, you dump out the box of cereal, you get some kind of prize inside. And one of the things we get is called a secret decoder ring. So what I want to do here, let's can we put up a picture of a secret decoder ring real quick? OK, so this is a classic old school kids decoder ring. Now, what I want to do is I've made my own decoder ring right here and I'd like us to take a little peek at this guy. And what you're going to see here is I basically got a wheel with all the letters of the alphabet, A through Z, and on the inside, I've got letters of the alphabet, A through Z. So right now I've got them lined up at A, B to B, C to see. Now, what I can do to make a secret code is let's say I can turn this to I could rotate this two times. And what we can do is we can take our original plain information, what we call the plain text, our message that we want to encrypt and we just change the letters. So we call this substitution. What we'll do is we'll take one value and substitute for another. Now, in this case, I've rotated it twice. So we actually have a term for this. We call it R t two just like that. And if I turned it three times, it would be R three now. So we can take like the word ace AC and I can change AC to see. E! G get the idea, so that's the cornerstone of the SESAR cipher, so. To convert something with a Caesar cipher and in fact, let's just go through the process real quick. Now, what I'm going to do, let's put up a piece of plain text that we want to encrypt. We attack at dawn. So here it is. We attack at dawn. Now, first, we are going to get rid of all the spaces. So now just says we attack at dawn, very readable. We don't worry about upper or lower case in this particular situation. Now, let's go ahead and put our groovy little. Secret decoder ring up there and let's go ahead and turn it in this particular case five times. All right, so we're doing an hour on five, so let's turn it one, two, three, four, five times. So now what we can do is by using the secret decoder ring, we can go ahead and encrypt. We attack at dawn as follows. So what we now have generated is a classic Caesar cipher. Now there's a problem with Caesar ciphers and the biggest problem we have with them more than anything else is that, in fact, people who buy crossword puzzle books will pay money to be able to do this is that we can. Decrypt them, we can just by looking at them, we can provide what's known as cryptanalysis, cryptanalysis is breaking these encrypted codes. So the problem is, is that anybody who's good at these things could pretty easily crack this. So the SESAR cipher, even though it is a substitution cipher, does have the problem is that it's just too easy to predict what this is because we're used to looking at words. So what I want to do is make it a little bit more challenging. The first thing I'd like to try to do is I want to bring in something called the vision, a cipher. The cornerstone of Vision A is that it's really just a SESAR cipher with a little bit of extra confusion involved. So what I've got here is a table that shows all the possible Caesar cyphers. There are so herup at the top. We're going to have the word plaintext. I'll show you how that works in just a minute. And then you'll see on the far left hand side, it says zero through twenty five. So these are all the possible ROTC values you can have from our rotis. Zero, which means A equals A equals B all the way down to twenty five. So what we're going to do let's hold onto this for a minute and now let's go ahead and start with a piece of plain text. Let's use we attack at dawn one more time. And what I'm going to do this time is we're going to apply a key. The key is simply a word that's going to help us do this encryption. In this particular case, I'm going to use the word face F, a, c, e. Now, what I'm going to do is I'm going to put F, a, c, e above the first four letters of we attack at dawn. So here we go, Fassie. And then I'm going to just keep repeating that. So we put face again. I'm going to put face again and you'll see I've got two letters left over. No big deal, I just put F a and what we've done is we have applied a key to our plaintext. Now what we're going to do is we're going to use the key to change the SESAR cipher rotty value for every single letter. So let's go ahead and do this. Now, what I'm going to do is I'm going to reference my little chart here. So the first letter of the plaintext is the W and we so here's the W up at the top. And the. Key value is F, so let's go down on the Y axis here till we get to an F now you see that F, you'll see the number five right next to it. So this is R five. So all I need to do is do the intersection of these and we get the letter B. Great. Let's do it again now in this case, the second time it's the letter E from we and in this particular case, the key value is A, which is kind of interesting because that's our zero, but that still works. So we start up at the top, find the letter E, then we find that A and in this case, because it's R zero, by coincidence, E is going to stay as E. Let's do the third volume now, this time it's the AI is an attack, so we go up the top, there's the letter A and the key value is C is in Charlie. So we go down to the C, that's R two. And we then see that the letter A. is now going to be C. OK, let's do one more real quick. In this particular case, it's the first T in attack. So we come over to the Ts and now the key value is E is an E is in phase. So we go down here, that's r t for we do the intersection and now we've got an X. So the first four letters of our encrypted code is B, C, X, so let's go ahead and run through and do the rest of these real quick. Just put those in for you. And we have now encrypted in the vision a style. So the beauty of the Veja day is that it actually gives us all the pieces we need to create a classic piece of cryptography. Number one, we have an algorithm and the algorithm are the different types of SESAR ciphers and the rotation's. And second, we have a key and the key allows us to make any type of changes we want within our zero to twenty five to be able to encrypt our values. Any algorithm out there is going to use a key in today's world. So when we're talking about cryptography today, we're always going to be talking about algorithms and keys. Now, the problem with the vision AI is that, well, number one, it's surprisingly trackable. Isn't that interesting? But the bigger problem is, is visionary works just great for letters of the alphabet? Unfortunately, it's terrible for encrypting. Pictures or SQL databases or your credit card information in the computer world, everything is binary, everything is ones and zeros. So what we need to do is come up with algorithms that provide the type of encryptions and descriptions we need to encrypt and decrypt long strings of just ones and zeros. Now, if you look at a string of ones and zeros, you go, how does anybody make anything out of this? Will they do that? There's you've got a string of ones and zeros may look like nothing to you, to a human being, but to Microsoft Word, that could be a word document or it could be a voice over IP conversation, or it could be a database stored on a hard drive. I don't know. But just because as human beings, we look at long strings of ones and zeros and get confused. Trust me, the computers don't. What we need to do, though, is we need to come up with algorithms which, unlike Caesar's or vision visionaries, that will work with binary data. Now, luckily for us, there are a lot of different ways to do this. So what we're going to do is I've got an example of a algorithm we're going to use that encrypts a simple phrase that we're going to we're going to convert those to binary, by the way. And we're going to do this using a very interesting type of binary calculation called exclusively for our first encryption. I'm going to encrypt my name. So here's my name, Mike. Mike. Now, the first thing we have to do is we're going to have to convert this to the binary that a computer would use. So I'm going to be using the binary equivalents of these texts values. So let me go ahead and convert these into their binary equivalents. And anybody who's ever looked at ASCII code or Unicode should be aware that we can convert these into binary. OK, so here we go. So here's m i e converted into binary. Now notice that each character takes eight binary digits, so we've got thirty two bits of data that we need to encrypt. So that's our clear text. Now, in order to do this, we're going to need two things. First of all, we're going to need an algorithm and then we're going to need a key. Now keep in mind, what I'm making up is like the most simple version of encryption you can possibly do. So let's go ahead. First of all, set up our algorithm. Now, our algorithm is extremely simple, using what we call an exclusive or so here's the exclusive or this is what we call a truth table. So what I'm going to do is I'm going to choose because this Mike algorithm arbitrarily chooses. This is I'm going to be using a five bit key. Now, there's a reason I'm using a tiny, tiny shortcut like this in the real world. Keys can be thousands of bytes long, but for right now, we're just going to use a five bit key. So to make this work, let's start placing the key. So I'm going to put the key over the first five bits. So here at the letter M for Mike, and now we can look at this table and we can start doing the conversion. So let's convert those first two values. Then the next. Then the next. Then the next. OK, so now we've converted a whole key's worth, but in order to keep going, all we have to do is shlep that key right back up there, OK? In fact, let's go ahead and extend the key all the way out. So now the key. We just keep repeating it and you'll see here at the end, it doesn't quite line up. No problem. Just add whatever amount of key you need to go ahead and fill up the rest of this. So there we go. OK, so now we can go ahead and complete this now let's just do it fast, you can double check me if you want, but as we go through here using the exclusive or algorithm, we then create. Our ciphertext go ahead and spot check a couple of those for me and make sure I got them right. OK, beautiful now, so this is the ciphertext notice that we have an algorithm which is extremely simplistic. We have a key which is very, very simple and short, but we now have an absolutely perfect example of binary encryption. Now, to decrypt this, we'd simply reverse the process. So I'm not going to go through all that. But appreciate that we would take the ciphertext, play the place, the key up to it, and then basically run the algorithm backwards and then we would have the decrypted data. So even though we've only seen three types of encryption so far, keep in mind that these really do everything that we're going to be seeing in later episodes, just a lot more complicated. Now, a couple of things we need to think about here. First of all, what's interesting is that if we always have an algorithm and a key, there is a gentleman named Auguste Kirchhoff who came up with a very, very interesting concept. Kirkos Principle says this. As long as you don't know what the key is to an encryption, you can actually understand the algorithm completely. Now, this is really, really important. Today's big super duper encryption tools that we use out there to protect you on the Internet are all open standards. Everybody knows how the algorithms work. Now, you would think, wait a minute. Now, if I know how the lock works, in essence, wouldn't I be able to pick it easier? And the answer is, interestingly enough, no. In our society, by showing everybody the lock, everybody can check the lock to make sure it isn't pickleball. So when we talk about proprietary encryption, everybody gets nervous because if we don't all know how the lock works, we can't all test the lock to make it work. So Kirkos principle and something we stand to today simply says everybody knows the algorithm, but if you don't know the key, it's not going to do you any good. So the last thing I want to talk about in cryptography basics is the idea of what data are we encrypting, because in the world, data is all over the place. The first place we to think about is what we call data at rest. Now data, it simply means something stored on a hard drive or on optical media or on a thumb drive or whatever it might be. And in these types of cases, we encrypt the data when we put it onto the drive itself. So it sits on the stored media and encrypted format. The other one is called data in transit. So if I'm got to voice over IP call or I'm sending a text message. That data is moving, it's going through the Internets and all the different tubes, and is that data to be encrypted while the data is in transit or not? This is a big issue and the last one is data in process. So we take a big database and we pull it off of a hard drive and we start calculating on that database. So it's sitting in RAM or it's sitting in the CPU. Those are important areas for us to consider. When we're talking about cryptography, where are we going to be encrypting and decrypting that data? But. But.