Cryptography Basics

17 minutes
Share the link to this page
You need to purchase the class to view this lesson.
One-time Purchase
List Price:  $139.99
You save:  $40
List Price:  د.إ514.18
You save:  د.إ146.92
List Price:  A$179.52
You save:  A$51.29
List Price:  ৳11,871.62
You save:  ৳3,392.13
List Price:  CA$176.80
You save:  CA$50.51
CHF 88.62
List Price:  CHF 124.08
You save:  CHF 35.45
List Price:  kr855.96
You save:  kr244.57
List Price:  €115.06
You save:  €32.87
List Price:  £102.26
You save:  £29.22
List Price:  HK$1,085.49
You save:  HK$310.16
List Price:  ₹10,223.98
You save:  ₹2,921.34
List Price:  RM566.18
You save:  RM161.78
List Price:  ₦53,126.20
You save:  ₦15,180
List Price:  kr1,183.01
You save:  kr338.02
List Price:  NZ$193.55
You save:  NZ$55.30
List Price:  ₱6,723.08
You save:  ₱1,921.02
List Price:  ₨22,447.39
You save:  ₨6,414
List Price:  S$185.30
You save:  S$52.94
List Price:  ฿4,195.50
You save:  ฿1,198.80
List Price:  ₺1,029.66
You save:  ₺294.20
List Price:  B$728.03
You save:  B$208.02
List Price:  R2,105.83
You save:  R601.70
List Price:  Лв225.56
You save:  Лв64.45
List Price:  ₩153,297.25
You save:  ₩43,802.34
List Price:  ₪446.20
You save:  ₪127.49
Already have an account? Log In


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 obfuscation. 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 Steven. Andy 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 Steven 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, Ah, 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 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 has ever been around is something called the Caesar 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. Okay, 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, the alphabet A through Z. So right now I've got them lined up at a B to B, C to C. Now what I can do to make a secret code is let's say I can turn this to I can rotate this two times. And what we can do is we can take our original plane information, what we call the plaintext, 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 our OT, two, just like that. And if I turned it three times, it would be our ot three now. So we can take like the word AC, AC, and I can change AC E to c, e. g, get the idea. So that's the cornerstone of the Caesar cipher. So to convert something with a Caesar Cipher, and Matter of fact, let's just go through the process real quick.

Now what I'm going to do, let's put A piece of plain text that we want to encrypt, we attack at dawn. So here it is, we attack a dog. Now first thing we're going to do get rid of all the spaces. So now just says we attack a dog very readable. We don't worry about upper lowercase 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 R ot five. So let's turn it 12345 times. So now what we can do is by using the secret decoder ring, we can go ahead and encrypt, we attack it gone 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 the more than anything else is that in fact, people buy crossword puzzle books, will pay money to be able to do this is that we can do crypt them, we can just by looking at them, we can provide what's known as crypt analysis. crypt analysis 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 Caesar 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 VGA cipher.

The cornerstone of vision a cipher is that it's really just a Caesar Cipher with a little bit of extra confusion involved. So what I've got here is a table that shows all the possible Caesar ciphers there are. So here up at the top, we're gonna 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 25. So these are all the possible ROTC values you can have from ROTC, zero, which means a equals A B equals b, all the way down to ROTC 25.

So, what we're going to do, let's hold on to 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, AC E. Now what I'm going to do is I'm going to put f AC e above the first four letters of attack at dawn. So here we go f AC E, 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 leftover, no big deal I'll just put FA and what we've done is we have applied a key to our plaintext.

Now what we're going to do is right We're going to use the key to change the Caesar Cipher ROTC 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 plain text is the W and V. 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, then you see that F, you'll see the number five right next to it. So this is our ot 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 V. And in this particular case, the key value is a which is kind of interesting because that's ROTC zero but that still works. So we start up at the top, find the letter E. Then we find a and in this case because it's ROTC zero, by coincidence, he is going to stay as he Let's do the third value. Now this time, it's the AES and attack. So we go up to the top, there's the letter A, and the key value is C as in Charlie, so we go down to the C, that's our ot two.

And we then see that the letter A is now going to be C. Okay, let's do one more real quick. In this particular case, it's the first tee and attack. So we come over to the T's. And now the key value is E as an ease and face. So we go down here, that's our ot four, we do the intersection, and now we've got an X. So the first four letters of our encrypted code is B EC 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 visa de is that it actually gives us all the pieces we need to create a classic piece cryptography. Number one, we have an algorithm and the algorithm are the different types of Caesar ciphers and the rotations. And second, we have a key. And the key allows us to make any type of changes we want within our ot zero to our ot 25 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 division a is that Well, number one, it's surprisingly crackable. Isn't that interesting? But the bigger problem is, is VGA 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 algebra. rhythms that provide the type of encryption and decryption, 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? Well, they do that there's you 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 voiceover 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 that computers don't. What we need to do though, is we need to come up with algorithms, which unlike Caesars, or vegenaise, 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 are binary by the way.

And we're going to do this using a very interesting type of binary calculation called Exclusive OR, for our first encryption, I'm going to encrypt my name. So here's my name, Mike MKE. 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 equivalence of the these texts values. So let me go ahead and convert these into their binary equivalence. And anybody who's ever looked at ASCII code, or Unicode should be aware that we can convert these into binary.

Okay, so here we go. So here's MI, K, he converted into binary. Now notice that each character takes eight binary digits. So we got 32 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 and 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 mic 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 short key like this in the real world.

Keys can be thousands of bytes long, but for right now, we're just gonna 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. Okay, so now we've converted a whole keys worth but In order to keep going, all we have to do is flip that key right back up there. Okay? In fact, let's go ahead and extend the key all the way out book. So now the key, do 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. Okay, so now we can go ahead and complete this. Now, let's just do it fast. You can double check 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.

Okay, beautiful. Now, so this is the cipher text. Notice that we have an algorithm which is extremely simplistic, we have a key which is very, very simple In short, but we now have an absolutely perfect example of binary encryption. Now to decrypt this, we'd simply reverse the prime 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 seen 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 if we always have an algorithm and a key, there's a gentleman named Auguste kerkhof, who came up with a very interesting concept. Kirk offs 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 superduper 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 pickable. So when we talk about proprietary encryptions, 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 Kirk offs 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 lastly, I want to talk about in cryptography basics is the idea of what data are we encrypting because in the IoT world, data is all over the place. The first place we might think about is what we call data at rest. Now data at rest simply means something stored on a hard drive or on optical media or on a thumb drive or whatever it might be. And indeed, These types of cases, we encrypt the data when we put it on to the drive itself.

So it sits on the stored media in encrypted format. The other one is called data in transit. So if I've got a voice over IP call, or I'm sending a text message, that data is moving, it's going through the internet's and all the different tubes. And is that data to be encrypted while the data is in transit or not? And 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 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

Sign Up


Share with friends, get 20% off
Invite your friends to TabletWise learning marketplace. For each purchase they make, you get 20% off (upto $10) on your next purchase.