The online banking, logins, and messaging apps we use every day are all encrypted. At the heart of that encryption is one very simple mathematical fact — multiplying two primes is easy, but factoring that product back into two primes is extremely hard.

Checking that 15 = 3×5 takes no time at all. Going the other way — "what's the prime factorization of 15?" — is still easy too. The trouble starts once the numbers get big. Multiplying two primes together to make a number over 600 digits long takes a computer no time at all, but working backward from that huge number to find the original two primes is effectively impossible, even for a supercomputer. RSA encryption uses exactly this asymmetry — "easy to multiply, hard to factor" — as its key.

5 × 11 Easy = 55 (If a 600-digit number) Extremely hard n → find p, q
Multiplying is easy, but factoring a large number back into its factors is extremely hard

You can try the idea out with small numbers. Pick primes p=5 and q=11, and n=p×q=55. Think of a message as a single number (m): you can encrypt it with a public key (e), then decrypt it back to the original number with a secret key (d) that only you know. Anyone can see the n and e used for encryption, but recovering the original message from them requires factoring n to find p and q. Our example (n=55) is solved instantly as 5×11, but real RSA uses an n over 600 digits long — estimated to take longer than the age of the universe to factor, even if every computer that exists today worked on it together.

RSA was created in 1977 by Rivest, Shamir, and Adleman (RSA takes the first letters of their names). The fact that "factoring being hard has never been mathematically proven, but in practice no one has ever found a fast method" is, in effect, what's protecting our online security right now.

There are other kinds of encryption too. Elliptic curve cryptography (ECC) relies on a different hard math problem — the discrete logarithm problem on an elliptic curve — instead of factoring. It can achieve similar security with a shorter key than RSA, so it's widely used in smartphones and cryptocurrency wallets. There's also a new threat on the horizon: quantum computers. A quantum algorithm called Shor's algorithm is known to be able to solve factoring far faster in theory, so once large, stable quantum computers arrive, both RSA and ECC could become vulnerable. That's why "post-quantum cryptography," built on new math problems that stay hard even for quantum computers, is an active area of research — the U.S. National Institute of Standards and Technology (NIST) announced the first official post-quantum cryptography standards in 2024. On our activity page, you can experience the difficulty of factoring firsthand with small numbers, and follow the encryption and decryption process step by step by generating your own RSA key.