RSA Calculator
Derive an RSA key (n, φ, d) from two primes and a public exponent, and walk through encryption/decryption. For learning only.
Category: Dev Tools
When to use?
Use it in cryptography courses and assignments to see how RSA works. Enter p and q to compute n, φ(n) and the private key d, then encrypt (c = mᵉ mod n) and decrypt (cᵈ mod n) an integer message m.
How to use
- Enter two primes p, q and a public exponent e (or generate random primes).
- Review the derived n, φ(n) and private key d.
- Enter a message integer m to see the ciphertext and decrypted result.
Input Explanation
p and q must be distinct primes; e must satisfy 1 < e < φ(n) and be coprime with φ(n); m must satisfy 0 ≤ m < n.
Calculation Basis
Using BigInt, it computes n = p×q and φ(n) = (p−1)(q−1), finds d = e⁻¹ mod φ(n) with the extended Euclidean algorithm, and encrypts/decrypts via square-and-multiply modular exponentiation.
Usage Examples
- Learning cryptography - Follow RSA key generation and encryption step by step.
- Checking assignments - Verify hand-computed RSA results quickly.
Examples
- p=61, q=53, e=17 → n=3233, φ=3120, d=2753
- m=65 → c=2790 → decrypts back to 65
Cautions
- This tool is for learning and verifying RSA math only. Do not use these keys for real encryption or authentication.
- Real security needs 2048-bit+ keys and padding (e.g. OAEP); small primes are trivially broken.
FAQ
Why the "not prime" error?
p and q must both be prime, or the key cannot be derived.
What value should e be?
In practice 65537 is common; it just needs to be coprime with φ(n).
Can I use it for real encryption?
No. It is educational, with small keys and no padding, so it is not secure.
Related Tools
- Hash Generator - Convert text into SHA-1, SHA-256, and SHA-512 hashes.
- Number Base Converter - Convert between binary, octal, decimal, and hexadecimal.
- Base64 Converter - Encode text to Base64 or decode a Base64 string back to text.
- JSON Formatter - Beautify or minify JSON strings instantly and check for validity errors.
- UUID Generator - Generate up to 20 cryptographically secure UUID v4 values at once.
- Password Generator - Generate secure random passwords in the browser by choosing length, character set, and count.