Lesson 4 of 4 · Open

Secret writing: encryption

How a message stays secret even though it passes through strangers' hands.

A message to your bank travels in packets through many routers that belong to strangers. Whoever runs one of them could look inside. A code alone does not protect it: traffic light colors and Morse code are open to everyone, and anyone who knows the code table can read along. How does a message stay secret even though it passes through strangers' hands?

The answer is to encrypt it: the readable message, the plaintext, is turned into a ciphertext that looks unreadable, using a secret key. Only someone who knows the key can decrypt the ciphertext, that is, turn it back into the plaintext.

New terms

plaintext
the readable message before it is encrypted
ciphertext
the encrypted message, unreadable without the key
key
the secret that sets how the encryption works, such as a number
encrypt
to turn the plaintext into a ciphertext using the key
decrypt
to turn the ciphertext back into the plaintext using the key

The shift

A very old method is said to have been used by Julius Caesar: each letter is moved forward a fixed number of places in the alphabet. This number is the key. With key 3, A becomes D, B becomes E, and C becomes F. After Z, it continues at A again: X becomes A, Y becomes B, Z becomes C.

PlaintextCiphertext, key 3
A B C D ED E F G H
F G H I JI J K L M
K L M N ON O P Q R
P Q R S TS T U V W
U V W X Y ZX Y Z A B C

Example

HELLO with key 3

Each letter moves three places forward. That gives the ciphertext, and with the same key the plaintext comes back.

  1. H becomes K
  2. E becomes H
  3. L becomes O, twice
  4. O becomes R
  5. Ciphertext: KHOOR

To decrypt, you go the same way back: each letter moves back by the key, toward A. Before A, it continues at Z at the end. So with key 3, the ciphertext letter A turns back into an X.

Quick check

Key 3: what does Y become when you encrypt?

How safe is the shift?

Someone who does not know the key can guess it. There are only 25 useful keys, from 1 to 25. A shift by 26 takes each letter once through the whole alphabet and back to its place, so the ciphertext would be the plaintext. A larger key works like a smaller one: 27 like 1, 28 like 2.

Example

Trying every key

Someone intercepted the ciphertext YFCN. Without the key, they move all the letters back by 1, 2, 3, and so on, one key after another:

  1. Key 1: XEBM
  2. Key 2: WDAL
  3. Key 3: VCZK
  4. Key 4: UBYJ
  5. Key 5: TAXI, a real word. The key has been found.

With pencil and paper, this takes a few minutes. A computer tries all 25 keys in a tiny fraction of a second. So the shift only keeps out people who do not even try.

How encryption works today

The small lock in the browser shows that the connection is encrypted, also called HTTPS. Today's methods do not shift letters, they calculate with numbers, since the data is made of bits anyway. Exactly how is simplified here. The key is a bit sequence of 128 bits or more.

Each bit doubles the number of possible keys. With 128 bits, that is a number with 39 digits. Even all the computers in the world together could not try that many keys in millions of years. The addresses on the packets stay readable, or no router could forward them. What gets encrypted is the contents.

Typical mistake

Mistaking a code for encryption, for example thinking a message in Morse code is secret. That cannot be right: the code table is open to everyone, and anyone can look it up and read along. A message only becomes secret through a key that only the sender and the recipient know.

Remember

Encrypting turns the plaintext into a ciphertext using a secret key. Only someone who knows the key can read it again. A code, on the other hand, anyone can look up.

Tasks

Three tasks complete the lesson. The order does not matter, the text above stays where it is.

Task 1 · Pairs

Which term means what?

Drag every card to its place, or tap it and then the place.

  • Plaintext
  • Ciphertext
  • Key
  • Encrypt
  • Decrypt

Task 2 · Input

The plaintext SOFA becomes the ciphertext ZVMH. Which key was used?

Enter the result.

Key =

Task 3 · Choice

PIZZA is encrypted with key 4. Which ciphertext comes out?

One answer is right.

Go deeper

Three more tasks, optional. They do not count for completing the lesson.

Task 4 · Sorting · optional

Code or encryption? Sort each row.

Drag every card into its group, or tap the group.

6 cards left

A connection with the lock in the browser

Task 5 · Several right · optional

An encrypted message travels in packets through strangers' routers. What can a router read?

Several answers are right. Pick all of them.

Task 6 · Input · optional

Someone moves each letter 34 places forward. Which key from 1 to 25 does the same?

Enter the result.

Key =

Back to the chapter