Shor’s algorithm and RSA: why factoring matters
How a public RSA key hides two primes, and how learning them gives away the private key.
8 min read · reviewed December 2026
RSA in four lines
- Choose two large secret primes p and q. Publish N = p·q and a number e.
- Compute φ = (p − 1)(q − 1) and the private number d with e·d ≡ 1 (mod φ).
- Encrypt a message m as c = m^e mod N.
- Decrypt with m = c^d mod N.
The weak link
Anyone who can factor N gets p and q, then φ, then d. The Toy RSA tab does exactly this for small primes. The security of real RSA is the belief that factoring a 2048-bit N is infeasible for classical computers. Shor’s algorithm would remove that belief once a machine large enough exists.
Which systems are affected
Shor’s paper also gave a method for discrete logarithms, which underlies Diffie-Hellman and elliptic-curve cryptography. So public-key systems based on those problems are all in scope. Symmetric ciphers and hash functions are affected only by Grover-type speed-ups, which are much milder.
What the response is
The response is not bigger RSA keys but new mathematics, known as post-quantum cryptography. The site’s myths page explains why larger RSA keys do not solve the problem.
Try it
Questions
Does Shor’s algorithm break encryption today?
No. No quantum computer currently built can run it at the sizes used in real keys. The estimates in the last guide show how far away that is.
Is post-quantum cryptography the same as quantum cryptography?
No. Post-quantum cryptography runs on ordinary computers with maths believed to resist quantum attacks. Quantum cryptography uses quantum physics itself.
Why do people worry before the machine exists?
Because data encrypted today can be recorded and decrypted later. That is the harvest-now-decrypt-later concern.
Read next
Sources and further reading
- P. W. Shor, “Polynomial-time algorithms for prime factorization and discrete logarithms on a quantum computer” (SIAM J. Comput. 1997, arXiv:quant-ph/9508027)
- M. Nielsen and I. Chuang, Quantum Computation and Quantum Information, chapter 5
- C. Gidney and M. Ekerå (2021), “How to factor 2048 bit RSA integers in 8 hours using 20 million noisy qubits”
- C. Gidney (2025), “How to factor 2048 bit RSA integers with less than a million noisy qubits”
- Algorithm page: Shor’s algorithm
Check the original sources for exact citations.