Grade 10 Computer Science · Encryption and trust
An operation easy to do and hard to reverse
The gap all encryption rests on.
A secret that passes through strangers’ devices
Every message you send passes through a chain of devices that are not yours, and none of them promises not to look. And still a secret can be sent that way. The answer is not in the route itself, but in one idea that needs no formula at all. What is it?
In grade eight you learned that the internet passes information through a chain of devices that are not yours. The question left open is how something secret can nonetheless be sent along such a route. The answer is not in the route — it is in one mathematical idea, which can be understood with no formula at all.
import hashlib
text = "the quick brown fox"
digest = hashlib.sha256(text.encode()).hexdigest()
print(digest[:16]) # a fixed-length fingerprint
# changing one letter changes the whole fingerprint
other = hashlib.sha256("the quick brown fix".encode()).hexdigest()
print(digest[:16], other[:16])A fingerprint and not encryption
The operation in the example is called hashing, and it is important not to confuse it with encryption. Encryption is meant to be opened again by whoever has a key; hashing is not meant to be opened at all, not even by you. It produces a fixed-length number from any input, such that changing one letter replaces the entire result. So it is a tool for checking whether something changed — and not a tool for hiding content.
| The tool | Meant for… | Opens again |
|---|---|---|
| Hashing | Checking whether something changed | No |
| Encryption | Hiding content | With a key |
Example 1 — why one letter changes everything
- The operation mixes the whole input.
- Every bit affects the whole result.
- So a small change is seen at once.
Example 2 — why “not worthwhile” suffices
- Breaking is possible in principle.
- It needs more time than exists.
- So no one tries.