Math stories
How Prime Numbers Keep Your Data Safe (RSA With Small Numbers)
9 min read · Updated September 26, 2026 · by the SolveCalcPro editorial team

- Multiplying two primes is easy; factoring the result is hard for big numbers.
- RSA uses this to let anyone lock a message that only the key-holder can open.
- Our example is a toy: never use small keys for real security.
- Real keys have hundreds of digits.
Every time you shop online or log in to a website, your browser and the site agree on a secret using mathematics that has been studied for thousands of years: prime numbers. Here is a small worked example of the idea behind RSA, one of the best-known public-key systems.
Easy one way, hard the other way
Multiplying 61 × 53 = 3,233 takes seconds. But if I hand you 3,233 and ask for its two prime factors, you need to search. For small numbers that is quick (try our prime factorization calculator). For a number with hundreds of digits, no known ordinary computer method can do it in a practical time.
The idea of public and private keys
Public-key encryption uses two keys. A public key that anyone can use to lock (encrypt) a message, and a private key that only the owner has to unlock (decrypt) it. The public key can be published openly because working out the private key from it requires factoring a huge number.
A toy RSA example
- Pick two primes: p = 61 and q = 53.
- Compute n = p × q = 3,233. This is part of the public key.
- Compute φ = (p − 1)(q − 1) = 60 × 52 = 3,120.
- Choose a public exponent e = 17 (coprime to 3,120).
- Find the private exponent d with d × e ≡ 1 (mod 3,120): d = 2,753, since 2,753 × 17 = 46,801 = 15 × 3,120 + 1.
The public key is (n = 3,233, e = 17); the private key is d = 2,753.
Encrypting and decrypting
To send the number m = 65, compute c = mᵉ mod n = 65¹⁷ mod 3,233 = 2,790. To decrypt, compute cᵈ mod n = 2,790²⁷⁵³ mod 3,233 = 65, the original message. Anyone can encrypt with the public key, but only someone knowing d can easily decrypt.
Why real keys are enormous
Real RSA keys use numbers with 2,048 bits or more, which is around 617 decimal digits. At that size, factoring n is far beyond today’s computers. Our toy example is trivial to break, and it should never be used for real security.
The future
A large enough quantum computer could factor big numbers efficiently using a method known as Shor’s algorithm, so researchers and standards bodies are developing new “post-quantum” systems. Number theory remains at the heart of security.
Try the pieces yourself
Use the prime number checker to see which numbers are prime and the GCF calculator to check that e and φ share no common factor. Learn more in prime and composite numbers.
Frequently asked questions
What is public-key cryptography?
A system with two keys: a public one to encrypt and a private one to decrypt.
Why are prime numbers used?
Multiplying two large primes is easy, but factoring the product is very hard.
Is RSA still used?
Yes, widely, alongside other systems, though standards are evolving.
Can I use this toy example to protect data?
No. Small keys are trivially breakable. Use standard, well-tested software.
Try the tools
Learn the method
Keep reading
Written and reviewed by the SolveCalcPro editorial team. Found an error? Tell us. See our editorial policy.