Okay, start the timer—I have exactly 6 minutes
to explain how the world’s most advanced encryption algorithm works before I have to
sell you a subscription to a stock photo website. We’re going to be talking about the Advanced
Encryption Standard—otherwise known as the Rijndael algorithm—which is the encryption
used by the NSA, Google, Facebook, and any other organization that doesn’t want you
stealing their data about them stealing your data. It cannot be broken, and brute-forcing your
way through the algorithm would take the world’s most powerful computer longer than the entire
universe has existed. How does it work? Well, let’s see if I can explain. AES is what’s called a “block cipher,”
which means that the first thing that it does is take your message and break it up into
blocks that are, basically, 4 letters by 4 letters.
If I’m sending the FBI a very sensitive
tip on Facebook Messenger, for example, that message is going to be encrypted 16 characters
at a time. I know that putting them in a box like this
makes them kind of hard to read, but believe it or not, we’re not even done encrypting
them. This next step in the encryption process is
the most important—if you’re gonna try and fail to impress a woman at a bar by explaining
the NSA’s standard of encryption, this is the part you’ve gotta get right. We’re going to take the block and add our
key to it; this key is basically the password that lets us encrypt and decrypt the text;
it’ll be a string of letters and numbers that can be one of three different lengths:
128 bits, 192 bits, or 256 bits, depending on whether you want it to take several trillion
years to crack, or if you can settle for a measly billion.
Now, if you majored in math back in kindergarten,
you might’ve realized that there’s a little problem here: addition is a thing that you
do with numbers, not state secrets. So we’re going to have to do something a
little clever here and combine these strings of text with a function that’s the basis
for most encryption algorithms: XOR. You see, since we’re dealing with computers
here, each letter is just 8 binary bits dressed up in a fancy hat. But you can’t add those numbers to each
other like normal numbers, or you might end up with a 2, and if you have a 2 your computer
will have some kind of existential crisis. So instead, you add them by checking if each
digit is the same or different, one digit at a time: if you have a 1 and a 0 you get
a 1, if you have a 0 and a 1 you get a 1, if you have two zeroes you get a zero, and
if you have two ones you get a 0.
So, just as an example, I’m gonna show you
what it looks like when you encrypt a one-letter long message with a one-letter long password:
that’s a zero, zero, one, a whole bunch of zeroes, and a one. And viola, now no one will ever know that
I said lower-case q. The cool thing about this is that if you take
the resulting encrypted text—in this case it happens to be an exclamation mark—and
do the exact same thing with the exact same password, you end up with the text that you
started with. So we’re going to go ahead and do this with
every character in our block, and we’ll end up with an entirely new block of encrypted
text—this is already pretty secure, but we’re just getting started. Next, we’re going to take everything in
our block, convert it to hexadecimal, and then substitute every single character with
a character from this table, the Rijdael S-box—not to be confused with the Rijndael Xbox, which
is the worst console that I’ve ever used. But this table is pretty simple; basically
if our character is 4f, we’ll find 4, find f, and see that we’ve gotta replace it with
84.
I could spend an hour talking about why this
box is such a good box, but all you really need to understand is that the numbers in
it are laid out so randomly that any patterns that might’ve been noticeable in the last
step will be a lot harder to spot. Now, we’re gonna take our shiny new letters
and shift them around a bit—the second row gets shifted one space, the third row gets
shifted two, and the fourth row gets shifted three.
This is called “diffusion,” and it’s
important because it gets rid of any statistical relationships that give you a clue as to what
character translates to what; if one character always has the same character appear after
it, it might be more likely to be “q” and “u,” for example. But now that the text is all mixed up, those
relationships are gonna disappear. For the next step, you’re gonna have to
pause the video and go learn linear algebra—you can probably knock it out in just a couple
of months by taking night classes at your local community college, so go ahead and do
that and then we’ll continue.
Okay, welcome back to the video. Now that you know linear algebra, this next
step is a breeze. You’re just going to take every column in
the block and multiply them by this matrix. This is basically also a way of doing diffusion,
and it gives us the block that we’re gonna take into our final step. So, remember all those minutes ago when I
talked about adding your key to the unencrypted block of text? Well I was lying to you, but only because
you weren’t ready to handle the truth.
You see, we didn’t actually add the key
there. We took the key and split it up into a bunch
of different subkeys using an algorithm that I super don’t have time to explain. In that first step, we added subkey 0, and
now, after all of those other steps, we’re going to add subkey 1 using the same technique—that’s
the end of round 1. Good job, we’re now about 10% of the way
through encrypting 16 letters. Now you’re going to do everything that we
just did 10-14 more times, depending on the length of the key you’re using, and that
includes taking those community college classes. And then, voila, you have an encrypted block
of text. So long as you have the original key, every
single step that we took is reversible—you just have to do it all backwards, in the right
order, to get the text that we started with. But if you don’t have the key, the only
way you can turn this into this is by… well, guessing the key. You just have to guess, approximately, this
many times.
Now stop the timer, because it’s time to
talk about Storyblocks. If you watch my videos and have any interest
in making your own edutaining video essays for YouTube, I can’t recommend StoryBlocks
enough. I used Storyblocks to get these channels off
the ground, and I still use them to this day; they give you everything you need to get your
channel off the ground—most stock footage sites charge you for each clip that you use,
and that’s just not sustainable for someone trying to break into YouTube. Storyblocks, on the other hand, uses an annual
subscription model, which gets you unlimited access to everything for less than those other
sites charge for a single clip. And in addition to their massive library of
footage, your subscription also gets you access to things like sound effects, background music,
Adobe After Effects templates—basically, everything you need in your creator toolkit
to give your channels some serious polish. If you’re going to make any kind of investment
in creating any kind of video, Storyblocks is the perfect starting place—just click
the button on screen or head over to storyblocks.com/hai to sign up, and you’ll be supporting HAI
while you’re at it.