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 obvious
occasion obvious occasion 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 theres a lot of different ways we can do obfuscation to provide confidentiality What are the things
we can do is diffusion.
So here is a picture of my grandson right here.
Let's take a look at that that Steve and then the 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 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 and it 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
Stephen.
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 has ever been around is something called the
Sezer 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 and you'd get some kind of prize inside.
And one of the things we'd 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 Correct.
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 the alphabet aither Z.
So right now I've got them lined up eight a b to b c to see now what I can do to make a secret code.
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 plain text 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 o t to.
Just like that.
And if I turned it three times it would be Arati 3.
Now so we can take like the word ace A C E.
And I can change a c e to see.
G get the idea.
So that's the cornerstone of the Sezer cipher.
So to convert something with a Caesar cipher and perfect that 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 do get rid of all the spaces.
So now it 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 OT 5.
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 Sezer ciphers and the biggest problem we have with the more Anything else
is that in fact people who like 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 Caesar
cipher even though it is a substitution cypher 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 V-J 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 Sezer ciphers there are.
So here at the top we're going to have the word plain text I'll show you how that works.
Just a minute and then you'll see on the far left hand side it says 0 through 25.
So these are all the possible Arati values you can have from our zero which means a equals a big will
be all the way down to our OT 25.
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 plaintexts 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 above the first four letters of we attack at dawn.
So here we go F A C and then I'm going to just keep repeating that so it put face again.
I'm going to put a face again and you'll see I've got two letters left over.
No big deal.
I just put a.
And what we've done is we have applied a key to our plain text.
Now what we're going to do is we're going to use the key to change the Caesar cipher OT 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 in 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..
They see that f you'll see the number five right next to it.
So this is Aro T5.
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 goatees
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 our OT 0.
By coincidence e is going to stay as e.
Let's do the third value now this time it's the A's in attack.
So we go up the top there's the letter A and the key value is C is Charlie.
So we go down to the C.
That's our T2 and we then see that the letter A is now going to b c.
Ok let's do one more real quick.
In this particular case it's the first T and attack.
So we come over to the T's and now the key value is e is in is in phase so we go down here.
That's our code for we do the intersection.
And now we've got an X..
So the first four letters of our encrypted code is B E 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 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 Sezer 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 O.T. 0
to our code 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 the vision day is that well number one it's surprisingly crackable Isn't that interesting.
But the bigger problem is his vision a works just great for letters of the alphabet.
Unfortunately it's terrible for encrypting pictures or sequel 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 hot.
How does anybody make anything out of this will they do that.
There's a you've got a string of ones and zeros may look like nothing Utu 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'm 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 exclusive or for our first encryption.
I'm going to encrypt my name.
So here's my name Mike and I K E.
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 these text 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 there's n i k e.
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 gonna need an algorithm and
then we're going to need a key.
Now keep in mind what I'm making up is like the 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 piece worth.
But in order to keep going all we have to do is shlepped 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 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.
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 and spot check a couple of those for me and make sure I got them right.
OK.
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 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 to keep 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 August Kirchoff who came up with a very very interesting concept Kirchhoff's 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 walk everybody can check the lock to make sure it isn't pickle.
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 Kirchhoff's 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 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 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 in these types of cases we encrypt the data when we put it onto 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 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 when we start calculating on that database.
So it's sitting in RAM or its citizens CPQ.
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.
In.