PPolySim OS

RSA Public-Key Encryption

The algorithm that secures the internet, laid bare. Pick two primes, generate a key pair, and watch a message get encrypted and decrypted step by step.

RSA Public-Key EncryptionLive
message
42
↓ encrypt: 42^3 mod 391
ciphertext
189
↓ decrypt: 189^235 mod 391
recovered
42

Controls

Presets

Prime p
Prime q
Message (number < n)

RSA rests on a one-way street: multiplying two big primes is easy, but factoring the product back apart is practically impossible. The public key (n, e) encrypts by raising the message to the power e mod n; only the private key d — computable only from the secret primes — can undo it. Real keys use 600-digit primes; these tiny ones just show the machinery.

▶ Run in Python

Data Inspector

Modulus n = p·q391
φ(n)352
Public key e3
Private key d235

Governing equation

Reading this result: The public key (n=391, e=3) turns 42 into ciphertext 189; only the private key d=235, derived from the secret primes, brings it back to 42. With primes this small, n could be factored instantly — real RSA uses 600-digit primes.

Runs locally in your browser — free forever. Scale to the cloud when reality gets heavy.

or unlock everything with Pro →
★ Sign in to save this setup
Save your tuned setup, or drop this simulation into your own site, docs, or course page.

How it works

RSA relies on a mathematical one-way street: multiplying two large primes is trivial, but factoring the product is infeasible. The public key encrypts by modular exponentiation; only the private key, derived from the secret primes, can reverse it. This demo uses tiny primes to reveal the machinery — real RSA uses numbers hundreds of digits long.

Ask the AI about this model

The math, the assumptions, real-world uses, or a code translation — explained for this exact simulation.

More Cryptography simulations

Frequently asked questions

Is this RSA encryption simulator tool really free?
Yes. RSA Public-Key Encryption runs entirely in your browser using your device's own compute, so local use is free forever. You only pay Compute Tokens if you scale a job to the cloud.
Do I need to install anything?
No. Everything runs client-side in a modern browser — no downloads, no license, no account required to start.
Can I save or share my simulation?
Create a free account to save projects, and use a shareable embed or minted DOI to publish a live, interactive version anywhere.
How accurate are the results?
The solver uses established numerical methods, but results are for research and educational purposes and should be validated against experiment or professional review before you rely on them.