1. Home
  2. Quantum Computing
  3. Shor's and Grover's Algorithms Explained Simply
Quantum Computing

Shor's and Grover's Algorithms Explained Simply

Published on November 13, 2026 · by Qubira 9 min read
Shor's and Grover's Algorithms Explained Simply

Two names come up in almost every article about quantum computers and encryption: Shor and Grover. They are usually mentioned in the same breath, as if they were twin threats, and that’s misleading. One of them is the reason governments are rewriting their cryptography standards. The other is a nice trick that mostly leaves your security alone. Understanding why takes about ten minutes and no equations, and it will make every quantum headline easier to read.

If the machines themselves are still fuzzy, start with our plain-English guide to quantum computing and the piece on what a qubit actually is, then come back.

🔑
The short versionShor's algorithm is exponentially faster than anything classical at factoring and discrete logs, so it endangers public-key encryption. Grover's algorithm only gives a square-root speedup at searching, so it nudges symmetric keys and hashes but doesn't break them. Neither can run at a useful scale on today's hardware.

A quantum algorithm is a choreography of interference

Before the two algorithms, one idea. A quantum computer is not a machine that tries every answer at once and hands you the right one. That popular picture is the single biggest source of confusion. What a qubit register can do is hold a combination of many states with an amplitude attached to each one, and those amplitudes behave like waves: they can add up or cancel out, the way ripples on a pond reinforce and erase one another.

A quantum algorithm is a carefully designed sequence of operations that makes the amplitudes of wrong answers cancel and the amplitude of the right answer grow, so that when you finally measure, you most likely see something useful. That’s the whole trick, and it’s why quantum algorithms are so hard to invent. You can’t just throw a problem at the hardware. You need a problem with the right shape, and a clever way to arrange the interference. Very few such algorithms are known, and the two famous ones sit at opposite ends of how much they achieve.

Shor’s algorithm: finding the hidden rhythm

In 1994 the mathematician Peter Shor showed that a quantum computer could factor large integers efficiently. Factoring means taking a number like 15 and finding that it’s 3 times 5. For small numbers that’s trivial. For a number a few hundred digits long, built by multiplying two huge primes together, the best known classical methods would take longer than the age of the universe on any hardware we can imagine. RSA encryption, which protected a vast share of internet traffic for decades, depends on exactly that difficulty.

Shor’s insight was that factoring can be turned into a different question: finding the period of a certain repeating function. Pick a number, raise it to successive powers, and look at the remainders after dividing by the number you want to factor. The remainders repeat in a cycle, and the length of that cycle leaks information about the factors. Classical computers have no shortcut for finding the cycle length of a huge number. A quantum computer does, thanks to a tool called the quantum Fourier transform, which is essentially a way of making interference reveal a hidden rhythm. Put the function into a superposition, apply the transform, and the amplitudes pile up on values related to the period. Measure, do a little classical arithmetic, and the factors fall out.

The same machinery also cracks the discrete logarithm problem, which is what protects elliptic-curve cryptography, the family used in modern HTTPS connections, messaging apps and cryptocurrency wallets. That’s the reason the wider industry is migrating to post-quantum cryptography, and why the question of whether quantum computers can break Bitcoin is a serious one rather than a meme.

The gap is the point. Shor’s algorithm isn’t a bit faster than the classical approaches, it’s in a different complexity class: the cost grows polynomially with the size of the number, where the best classical methods grow far faster. That’s what “exponential speedup” means here, and it’s rare.

Grover’s algorithm: a better way to search a haystack

Lov Grover published his algorithm in 1996, and it solves a more everyday problem: you have N possible answers, a way to check whether any candidate is correct, and no clue where the right one is. Classically you try them one by one, which takes about N attempts on average, N/2 if you’re lucky.

Grover’s method starts with an equal superposition over all candidates, then repeats a two-step loop. The first step flips the sign of the amplitude on the correct answer, which on its own changes nothing you could measure. The second step reflects all amplitudes about their average, which has the effect of boosting the marked one a little and shrinking the others. Repeat roughly the square root of N times and the correct answer dominates. Go on too long and the amplitude starts to drain away again, so knowing when to stop matters.

A square-root speedup is real: searching a million items takes around a thousand quantum steps instead of a million tries. But it is nowhere near the leap Shor delivers, and mathematicians have proved it can’t be improved for unstructured search. There’s no hidden rhythm to find, only a haystack, so interference can only do so much.

Side by side

Shor’s algorithmGrover’s algorithm
Year19941996
ProblemFactoring, discrete logarithmsUnstructured search
SpeedupExponential (super-polynomial)Quadratic (square root)
Key ingredientQuantum Fourier transform, period findingRepeated amplitude amplification
TargetsRSA, elliptic-curve cryptographyBrute-force search, symmetric keys, hashes
Practical threatSerious, long-termManageable with longer keys
Hardware neededLarge fault-tolerant machineAlso fault-tolerant, and overhead eats the gain

What it means for real security

Put the two side by side and the security picture is lopsided. Public-key schemes such as RSA and elliptic curves are the ones in real trouble, because Shor’s speedup removes the mathematical hardness they rest on. Symmetric encryption like AES and hash functions like SHA-256 are in much better shape. Against Grover’s algorithm, a key effectively loses half its bits of strength, so AES-128 acts like a 64-bit key in a perfect quantum attack and AES-256 acts like a 128-bit one, which remains far beyond reach. The standard advice is therefore dull: use 256-bit symmetric keys and keep going.

There’s a second reason Grover is less frightening than it first sounds. Each Grover iteration has to run the entire function being searched, and the iterations can’t easily be spread across many machines, because the speedup comes from running them in sequence. Once you account for the slow, error-corrected hardware these algorithms would actually run on, a quantum attacker would need an absurd amount of time per key. Many researchers conclude that the quadratic advantage mostly evaporates against a well-sized key.

Shor vs. RSA and elliptic curves
Breaks them (eventually)
Grover vs. AES-128
Weakens, still strong
Grover vs. AES-256
Comfortable margin
Either, on today's hardware
Not remotely

These bars are our qualitative reading of the threat, not measured data.

Why you haven’t heard of a quantum factoring record

You may have seen claims that a quantum computer factored a number. Look closely and you’ll find they involve numbers like 15 or 21, and often use shortcuts that bake in knowledge of the answer. Running Shor’s algorithm on a 2048-bit RSA key requires thousands of logical qubits, each of which is made from many noisy physical qubits working together, as we explain in our guide to quantum error correction. Published resource estimates have come down over the years as researchers found better ways to run the algorithm, but they still point to machines far larger and more reliable than anything built so far. We’d treat any confident date for “Q-Day” as a guess.

That is also why the transition to post-quantum cryptography is happening now rather than after the fact. Data encrypted today can be recorded and stored, then decrypted years later when the hardware arrives, an approach often called “harvest now, decrypt later”. For information that has to stay secret for decades, waiting isn’t an option. For your holiday photos, it probably is.

What quantum computers might be good at instead

It’s worth ending on a more cheerful note, because breaking codes is the least productive use of these machines. The application most researchers are genuinely optimistic about is simulating quantum systems: molecules, catalysts, materials. Nature is quantum, and a quantum computer models it directly instead of approximating it painfully on classical hardware. Richard Feynman proposed exactly that idea in the early 1980s, well before Shor. Our overview of what quantum computing is good for today goes through the realistic candidates, and the sober answer on whether it will speed up machine learning is also worth a read.

If you’d like to see these ideas run rather than read about them, you can try a real quantum computer for free, and build your first circuit with our Qiskit walkthrough.

Learn the real maths, gently

Our pick

Quantum computing books for beginners

A good introductory book walks through superposition, interference and these two algorithms step by step, with just enough linear algebra to make it click. See also our quantum computing books review.

See quantum computing books on Amazon →

Our take

We find Shor and Grover a useful pair to keep in your head precisely because they’re so different. Shor shows what happens when a problem has hidden structure that interference can exploit: the speedup is enormous, and it rewrites the rules of public-key security. Grover shows the ceiling when there is no structure: a modest square-root gain that careful engineering absorbs. Most of what’s being sold as “quantum” in headlines sits closer to Grover’s end of that spectrum than to Shor’s. More guides are waiting in our Quantum Computing category.

FAQ

What does Shor's algorithm do?
It finds the prime factors of a large number, and solves the related discrete logarithm problem, far faster than any known classical method. That is why it threatens RSA and elliptic-curve cryptography once a large, error-corrected quantum computer exists.
What does Grover's algorithm do?
It searches an unstructured collection of N possibilities in roughly the square root of N steps instead of N. It's a quadratic speedup: useful, but far weaker than the dramatic speedup Shor's algorithm offers.
Can Shor's algorithm break encryption today?
No. Running it on keys of real-world size needs a fault-tolerant machine with a very large number of reliable logical qubits. Today's devices are far from that. The largest numbers factored by genuine runs of Shor's algorithm are tiny.
Does Grover's algorithm break AES?
Not in any practical sense. It effectively halves the security of a symmetric key, so AES-128 behaves like a 64-bit key against an ideal quantum attacker. Using AES-256 restores a comfortable margin.
Why is Shor's algorithm so much faster than Grover's?
Shor exploits hidden mathematical structure (periodicity) in the factoring problem, using the quantum Fourier transform. Grover has no structure to exploit: it just amplifies the right answer in an unstructured search, which only gives a square-root gain.
Are there other important quantum algorithms?
Yes. Quantum simulation of molecules and materials is widely expected to be the first genuinely useful application, alongside algorithms for linear systems, optimisation heuristics and quantum phase estimation, which Shor's algorithm itself relies on.
Do I need to understand the maths to follow this?
No. The core ideas, interference and exploiting structure, can be grasped without equations, and that is how we explain them here.