CS 100 (Learn) — CS 100 (Web) — Module 11
NOTE: If your internet access is restricted and you do not have access to YouTube, we have provided alternate video links.
Note: This video transcript has been slightly modified. Corrections are marked with strikethrough, and alternative wording has been placed in [square brackets] to correct some of the awkward or confusing phrasing in the videos.
In this video we are going to introduce encryption.
We have already established that sending messages on the internet gets broken down into little tiny "postcards" of information and that you can send postcards from your computer which get transmitted to another computer or device and through the internet until it arrives at its destination.
But what happens if there is an "evildoer" in-between your computer and the destination?
As you send the postcard through the internet, the evildoer can intercept your message and then copy it somewhere else as it goes by.
Now [they] have a copy of your message [and] they can read what you were sending across the internet.
This is part of the reason why the postcard analogy works so well, because with a regular postcard it is not inside of an envelope so anyone who touches the postcard [along its path] from its source to its destination can read the contents of the postcard.
If you have an evil postman (as pictured here) who sees your postcard as it goes by it could copy out the contents of your postcard, or make a photocopy of it, or read your secret message that you are trying to send your friend.
This happens in the real world with regular postcards and this happens on the internet with packets.
Any device that is in-between the source and the destination can look at your packets and see the full contents of what they contain.
If we are interested in maintaining some security what we can do is encrypt our message.
I will [describe] how that is done but first let's get the picture straight: I, as the blue sender, take my postcard and I encrypt it using some fancy technique. I will represent that [encrypted postcard] as a red postcard. I send an encrypted message to my friend, and the evil postman in-between cannot interpret what the message says, because only my friend has the instructions on how to decrypt [the] message.
I, as the sender, encrypt my message. It is now unreadable unless you have this special information you need to decrypt a message and view it.
This will thwart our evil postman and we can do something like this on the internet as well.
Let's take a look at a simple technique you may have learned when you were in grade school on how to encrypt messages.
We are going to shift every letter by 3, so instead of sending you the letter "a" I will send you the letter "d", and instead of you sending you the letter "b" I will send you the letter "e" until "w" becomes "z" and we can wrap around: "z" will become "c".
This method is known as a Caesar cipher because it was used by Julius Caesar over 2,000 years ago so that should tell you how state-of-the-art this particular method is.
[However,] it captures everything we need to know about how encryption works. We are gonna have some encryption method (and trust us, today's computers use something more fancy than a Caesar cipher) but we also need a number that helps us use the encryption. In the Caesar cipher, we used three.
We also need to be able to decrypt our message, so if the recipient knows the number three and the method we use to encrypt the message, then they can decode the message and view it.
In today's world we do not use the Caesar cipher and we do not use numbers like three we use ginormous numbers to encrypt and decrypt our messages.
Right now, as you are communicating over the internet, big numbers are being used to encrypt and decrypt messages you send over the internet.
This particular method of encryption works fine as long as the sender and the receiver both have this special magic number. This allows them to encode and decode a message, [and] everything will work smoothly.
This works great if the sender and receiver can have a private conversation where nobody is listening... they could send the secret number back and forth between them.
That is not how the internet works, because if you are going to connect to a computer on the other side of the world, the very first contact I have will be done through packets over the internet so we will never have complete privacy.
We will never be able to exchange this number in secret without anybody knowing or intercepting it in-between.
If the person intercepting it gets that number, our encryption is broken and they can spy on everything we have done.
The problem now becomes: "How do I send you a message if we are only communicating over postcards (or things that are visible to the entire world)? How do I send a message to you that only you can receive?"