RSA Encryption / Decryption

Experiment with RSA encryption and decryption in your browser. Generate a demo key pair, see n, e, d, encrypt a message with the public key, and decrypt it with the private key. Includes step-by-step explanation of the RSA algorithm.

Full original guide (expanded)

RSA Encryption / Decryption

A browser-based, educational RSA lab: generate small demo keys, encrypt a short message with the public key, and decrypt with the private key. Good for learning the algorithm, not for real-world security.

⚠️ Educational only — uses small primes and naïve randomization. Do not send secrets.

1. Generate / enter keys

Click “Generate demo keys” to let the tool pick two primes and compute n, φ(n), e and d. Or paste your own n, e, d below.

2. Encrypt

We convert your message to UTF-16 code units and encrypt each unit separately: simple, visible, educational.

Ciphertext (array of big integers):

3. Decrypt

Paste the ciphertext array exactly as produced above, then decrypt with the private key d.

Decrypted message:

How RSA works (short)

RSA is based on modular arithmetic and the difficulty of factoring a large number \( n = p \times q \):

1. Choose two primes p, q
2. n = p · q
3. φ(n) = (p − 1)(q − 1)
4. Choose e s.t. 1 < e < φ(n) and gcd(e, φ(n)) = 1 (common: 65537)
5. Compute d ≡ e⁻¹ (mod φ(n))
6. Public key = (n, e), Private key = (n, d)

To encrypt a number \(m\): \( c = m^e \bmod n \). To decrypt: \( m = c^d \bmod n \).

Note: Real implementations use padding schemes (like OAEP) and big key sizes (2048+ bits). This page is intentionally simplified.


Audit: Complete
Formula (LaTeX) + variables + units
This section shows the formulas used by the calculator engine, plus variable definitions and units.
Formula (extracted LaTeX)
\[','\\]
','\
Formula (extracted text)
1. Choose two primes p, q 2. n = p · q 3. φ(n) = (p − 1)(q − 1) 4. Choose e s.t. 1 < e < φ(n) and gcd(e, φ(n)) = 1 (common: 65537) 5. Compute d ≡ e⁻¹ (mod φ(n)) 6. Public key = (n, e), Private key = (n, d)
Variables and units
  • No variables provided in audit spec.
Sources (authoritative):
Changelog
Version: 0.1.0-draft
Last code update: 2026-01-19
0.1.0-draft · 2026-01-19
  • Initial audit spec draft generated from HTML extraction (review required).
  • Verify formulas match the calculator engine and convert any text-only formulas to LaTeX.
  • Confirm sources are authoritative and relevant to the calculator methodology.
Verified by Ugo Candido on 2026-01-19
Profile · LinkedIn
Formulas

(Formulas preserved from original page content, if present.)

Version 0.1.0-draft
Citations

Add authoritative sources relevant to this calculator (standards bodies, manuals, official docs).

Changelog
  • 0.1.0-draft — 2026-01-19: Initial draft (review required).