Why do we use encryption
Imagine passing a letter through many hands without putting it in an envelope. Everyone who takes it and hands it on can read it as it is. A message sent over the internet with no protection is exactly that letter. Encryption turns it into a jumble of characters that cannot be read without a key. Even if someone grabs it along the way, they cannot make out what it says, and only the person with the right key can turn it back into the original text.
Text sent as it is can be read by anyone
A message does not go straight to the other person. It passes through a series of points along the way, such as routers, telecom equipment and relay servers, before it arrives. If the text is sent as it is, every place it passes can read it.
This untouched original text is called plaintext. Plaintext is like a letter without an envelope.
Tap the points along the path one at a time. Because it is plaintext, the contents show as they are at every point.
Whichever point you tapped, the same text showed as it was. Most points simply pass along what they receive, but the trouble is that even one of them could decide to read and copy the contents. That is even more of a concern on a road whose operator you do not know, such as public Wi-Fi.
Imagine passwords or card numbers travelling this way. So before sending, we lock the contents so others cannot read them, and that locking is encryption.
Locked, it becomes meaningless text
Encryption scrambles plaintext according to a set method so that it cannot be understood even when read. The locked text is called ciphertext. You can still see characters in ciphertext, but the meaning is gone; it is just a jumble.
The scrambling method works together with a key. The same method with a different key gives completely different ciphertext, and only that key can undo it.
Press lock to encrypt the plaintext. Readable text turns into meaningless ciphertext.
Pressing lock turned the clear text into characters you cannot make out. The contents were not erased; they were locked so they cannot be read without the key. This is where encryption differs from hashing. A hash makes a fingerprint that cannot be reversed, but encryption can be turned back into the original text by anyone who has the key.
So how does the jumble become the original text again? The answer lies in the key used to lock it.
Only the right key unlocks it
To read locked ciphertext again, you have to unlock it with a key. This is called decryption. With the right key, the jumble returns to the original plaintext, just as the matching key opens a lock.
A wrong key does not unlock it. So only people who have the key can see the contents, and no one in the middle without the key can turn the ciphertext back into plaintext.
Pick a key and press unlock. The right key brings back the original; a wrong key does not open it.
The right key brought back the original, and the wrong keys were blocked. That is what makes encryption useful. It is fine for the locking method itself to be widely known. In fact, a public method that many experts have tested for years is more trustworthy.
The real secret is the key alone. This principle, that the method can be public and only the key is hidden, is called Kerckhoffs's principle. So where does locking and unlocking actually protect us?
Protecting data both in transit and in storage
Encryption protects secrets in two main places. The first is in transit. If a message is encrypted while it crosses the internet through those intermediate points, anyone who intercepts it gets nothing but ciphertext.
The second is in storage. Even while files and data sit quietly on a phone or a server, someone could look at them if the device is lost or the server is breached. If they are stored encrypted, the stored copy cannot be read without the key.
Switch between in transit and at rest. In either case, what the snooper gets is only ciphertext, so the contents stay protected.
In transit or at rest, encrypted text was only a jumble without the key. Important data needs to be locked both when it is sent and when it is stored for the secret to be kept on both sides. Encryption only stops people from reading the contents, though; on its own it does not prove who sent a message or that it was not changed on the way. A later lesson covers that with digital signatures.
And one more thing remains. How do the people exchanging messages safely share the key they need to lock and unlock them?
Wrapping up
In short, plaintext sent as it is can be read by anyone on the road. Encryption locks plaintext with a key into meaningless ciphertext that only the right key can unlock, so only those who hold the key see the contents.
That keeps secrets safe both in transit and in storage. The locking method can be known; the secret lies in the key alone.
Tap the key points in order to review. (plaintext can be seen → locking makes ciphertext → only the right key unlocks it → protects transit and storage)
Now you hold the most basic tool for keeping secrets: lock, unlock only with the key, and protect data both when it is sent and when it is stored. But even a good lock is useless if the key is left lying around.
The next lesson looks at symmetric encryption, which locks and unlocks with the same single key, and runs into a tricky problem: how to hand that key to someone far away.