Nib asked, and Nib — askNib's tutor — drew the answer live at a whiteboard. This is the spoken transcript; enable JavaScript to watch it drawn.
how does encryption work with prime numbers
Here is a surprise: the primes never scramble your message. Their only job is to hide in plain sight, because multiplying them is easy and un-multiplying is not.
Scale it up. Real primes run to hundreds of digits, so a real key has 617 digits. The biggest such number factored in 2020 had only 250.
The second ingredient is clock arithmetic. Numbers wrap around, so on a twelve-hour clock fourteen o'clock lands on two. R-S-A does this on a clock with n hours.
In real R-S-A the clock has n hours: 3233 of them in our toy. Every locking and unlocking is just a jump around that clock.
Now the recipe. Pick two primes, multiply for the public n, then build a secret number from p minus one times q minus one. Choose e, solve for d.
The proof it works: e times d is 46801, which is fifteen times 3120 plus one. That extra one makes the wrap-around cancel and returns your message.
Eve sees only 3233 and 17. Getting 3120 means knowing 61 and 53, and computing it is as hard as factoring n. That is where the primes protect you.
So: two secret primes make a public n, clock arithmetic does the locking, and the primes are the trapdoor. A future quantum computer could break it, so new schemes are coming.
Primes are not the lock, they are the hidden hinge: easy to multiply, practically impossible to pull apart.