sciandu
Computer science

Computer science

Encryption

How messages turn into secret writing and why nobody can read along when you pay online.

What you need first

When you send a message or buy something online, your data travels across many computers that are not yours. Yet practically nobody along the way can read it. The reason is encryption, an idea older than any computer.

The Caesar shift

More than 2000 years ago, Julius Caesar protected his orders with one of the oldest secret scripts: he replaced every letter with the one a few places further along in the alphabet. With a shift of 3, A becomes D, B becomes E and HELLO becomes KHOOR. That shift is the key: whoever knows it simply shifts back and can read the message. To calculate with it, you number the letters: A sits at position 1, B at position 2, Z at position 26. Shifting then simply means adding. At the end of the alphabet you start over at the front, so with a shift of 3, X becomes A, Y becomes B and Z becomes C.

Caesar wheel
Shift3
PlainABCDEFGHIJKLMNOPQRSTUVWXYZ
CipherDEFGHIJKLMNOPQRSTUVWXYZABC

SECRET

VHFUHW

SECRET VHFUHW (key 3)
Try it: type a message, turn the shift and watch it become secret writing.

Why Caesar is easy to crack

The alphabet has 26 letters, so there are only 25 meaningful shifts. An attacker simply tries them all and checks which one produces readable text. After at most 25 attempts, every Caesar message is cracked. A good key therefore needs so many possibilities that trying them all becomes hopeless.

Modern encryption

Today's methods use huge key spaces: a common key is made of 128 zeros and ones, and that gives more possibilities than there are grains of sand on Earth. Even the fastest computers in the world would need longer than the age of the universe to try them all. That is exactly what sits behind the https in your browser's address bar: it shows you that your connection to the page is encrypted.

Exercises

0 of 6 solved

Time to try it yourself. You can't break anything, every attempt counts.

Why do you encrypt a message?

In the Caesar cipher, what is the key?

The letter C becomes an F. By how many places was it shifted?

Match each term around encryption to its meaning.

Key
Encrypting
Cracking
The https in the address bar

With a shift of 5, A turns into a different letter. At which position in the alphabet does that letter sit? (A is at position 1.)

A good key needs so many possibilities that becomes hopeless.

Where this leads