Here's the one fact this entire piece rests on: multiplying two numbers together is fast. Taking the answer and figuring out which two numbers were multiplied — factoring — is, for large enough numbers, staggeringly slow. That gap in difficulty between two directions of the same operation is called a one-way function, and it is, quite literally, what makes modern digital privacy and online banking possible. Try it yourself below.
Feel the asymmetry
Pick two prime numbers. Multiplying them is instant, no matter how big they are. Then watch how many steps it actually takes a computer to reverse the process — checking every possible factor, one by one, the way a computer with no shortcuts would have to.
Try the biggest primes in the list. The multiply side never changes. The factor side grows dramatically — and this is with a fast modern computer checking millions of candidates per second. Real-world encryption uses primes hundreds of digits long, at which point even every computer on Earth working together, using far smarter methods than this simple check, would need longer than the universe has existed.
Multiplication and factoring are the same operation, run in opposite directions — and one direction is easy while the other is, past a certain size, functionally impossible. That single asymmetry is the entire foundation of digital secrecy.
From asymmetry to a "public" lock
Here's the genuinely clever leap, discovered in the 1970s (Whitfield Diffie, Martin Hellman, and Ralph Merkle laid the groundwork; Ron Rivest, Adi Shamir, and Leonard Adleman turned it into the working system now called RSA, after their initials): if factoring is hard but multiplying is easy, you can build a lock that everyone is allowed to see and use to lock things — but that only one specific key can open.
The method: pick two large prime numbers and multiply them to get a number n. Publish n openly — anyone can use it to encrypt a message to you. But unlocking a message encrypted this way requires knowing the two original primes that were multiplied to make n — and finding them by factoring n, if it's large enough, is the "impossible" side of the asymmetry above. You keep the two original primes secret; that secret is your private key. The number n everyone can see is your public key. This is why it's called public-key cryptography — for the first time in the history of secret-keeping, two people who had never met and shared no secret in advance could still establish a private channel, in full view of an eavesdropper, because the lock and the key use fundamentally different math.
A tiny, real, working example
Real RSA keys use primes hundreds of digits long. But the math works identically at toy scale — small enough to compute by hand, large enough to actually demonstrate the mechanism. This example uses the classic textbook primes p = 61 and q = 53, giving a public key of n = 3233. Pick a small number below (representing a message) and watch it get locked with the public key, then unlocked with the private key — real modular arithmetic, computed live, not simulated:
Notice the encrypted number looks like total nonsense — and there is no shortcut back to the original message without the private key d, which itself can only be derived by first factoring n into its two original primes.
Why this is invisibly everywhere
The small padlock icon in your browser's address bar means this exact family of math (RSA and closely related methods) just ran, automatically, to protect your connection. It's what lets your bank verify it's really talking to you, what keeps a password you type from being readable by anyone monitoring the network, and what makes it possible for two strangers — your phone and a server on the other side of the planet — to agree on a shared secret over a channel either could be tapping. Every secure website, every encrypted message app, every "verified" software update rests on some version of the same one-way-function trick.
The asterisk: quantum computers change the math
Honesty requires one caveat. The entire scheme depends on factoring being hard for the kind of computers we currently have. In 1994, mathematician Peter Shor proved that a sufficiently large, stable quantum computer could factor large numbers efficiently — collapsing the very asymmetry this whole system depends on. Today's quantum computers are nowhere near large or stable enough to threaten real-world encryption keys, but the possibility is taken seriously enough that, in 2024, the US National Institute of Standards and Technology (NIST) finalized a new generation of post-quantum cryptography standards — encryption methods built on different, quantum-resistant math problems, designed to replace RSA-style systems before quantum computers become capable enough to matter. It's a live, active area of cryptographic engineering, not a settled question — a reminder that "impossible to break" in cryptography always really means "impossible with the computers we currently have," and that assumption is worth revisiting as computing itself changes.
Cryptography that secures the modern internet rests on a single asymmetry: multiplying two large primes is fast, but factoring the result back into those primes is, at sufficient size, functionally impossible for today's computers. Public-key cryptography (RSA and its relatives) turns that gap into a lock anyone can use and only one key can open — the public key is the product of two secret primes, and the private key depends on factoring it, which is the "impossible" direction. This is what makes secure communication between strangers, over an open network, possible at all — though quantum computing is a real, actively-managed future threat to the scheme, driving the current shift toward post-quantum cryptography standards.
Try this: run the factoring race above with the two largest primes in the list, then notice that your browser silently performs a version of the RSA walkthrough above every single time you visit a site starting with "https://".
Sources. RSA's core mechanism and history (Rivest, Shamir, Adleman, 1977; building on Diffie-Hellman-Merkle key exchange, 1976) is standard, well-documented cryptography. The tiny worked example (p=61, q=53, n=3233, e=17, d=2753) is a classic textbook illustration and is computed live above using real modular arithmetic. Peter Shor's 1994 factoring algorithm for quantum computers, and NIST's 2024 finalization of post-quantum cryptography standards (FIPS 203, 204, 205), are documented public record.
- 📘 The Code Book — Simon Singh (the full history of cryptography, brilliantly told, RSA included)
- 📘 Cryptography: A Very Short Introduction — Fred Piper & Sean Murphy (compact and rigorous)
- 🌐 NIST — first finalized post-quantum encryption standards (2024)
- 🌐 Companion piece in this library: The Most Beautiful Ideas in Math (primes as "the atoms of arithmetic")