Home/Tools/Security/RSA Playground

RSA Playground

Interactive RSA encryption demonstration with small primes to show the mathematics behind public key cryptography. Generate keys, encrypt/decrypt messages, and see why large primes matter.

100% Private - Runs Entirely in Your Browser
No data is sent to any server. All processing happens locally on your device.
Loading RSA Playground...
Loading interactive tool...

Need Professional Security Testing?

Our penetration testers find vulnerabilities before attackers do. Get a comprehensive security assessment.

What Is RSA Encryption

RSA (Rivest-Shamir-Adleman) is the first widely adopted public key cryptosystem, published in 1977. It enables secure communication, digital signatures, and key exchange without requiring parties to share a secret key in advance. RSA's security is based on the computational difficulty of factoring the product of two large prime numbers — a problem that remains intractable for classical computers at sufficient key sizes.

RSA is used in TLS/SSL certificates, PGP email encryption, code signing, secure boot, and countless other security protocols. While newer elliptic curve algorithms offer equivalent security with smaller keys, RSA remains foundational to understanding public key cryptography and is still the most widely deployed asymmetric algorithm.

How RSA Works

RSA key generation, encryption, and decryption follow these mathematical steps:

Key Generation

  1. Choose two large random primes p and q (each 1024+ bits for RSA-2048)
  2. Compute n = p x q (the modulus, used in both public and private keys)
  3. Compute phi(n) = (p-1)(q-1) (Euler's totient)
  4. Choose public exponent e (commonly 65537) such that gcd(e, phi(n)) = 1
  5. Compute private exponent d such that e x d = 1 mod phi(n)
  6. Public key: (n, e) — Private key: (n, d)

Operations

OperationFormulaUsed For
Encryptc = m^e mod nConfidentiality — encrypting data with the recipient's public key
Decryptm = c^d mod nDecrypting data with your private key
Signs = hash(m)^d mod nDigital signatures — proving authorship with your private key
Verifyhash(m) = s^e mod nVerifying a signature with the signer's public key

Key Size and Security

RSA Key SizeEquivalent Symmetric StrengthStatus
1024-bit~80-bitDeprecated — factorable with sufficient resources
2048-bit~112-bitMinimum acceptable — adequate through ~2030
3072-bit~128-bitRecommended for new deployments
4096-bit~152-bitLong-term security, but slower operations

Common Use Cases

  • Learning cryptography: Experiment with small RSA key sizes to understand modular arithmetic, key generation, and the relationship between public and private keys
  • Understanding TLS certificates: See how RSA key pairs underpin the certificate chain that secures HTTPS connections
  • Digital signature exploration: Sign and verify messages to understand how code signing, document signing, and certificate validation work
  • Security assessment: Evaluate whether systems use adequate RSA key sizes and proper padding schemes (OAEP vs PKCS#1 v1.5)
  • Post-quantum planning: Understand why RSA will be broken by Shor's algorithm on quantum computers and why migration to post-quantum algorithms is necessary

Best Practices

  1. Minimum 2048-bit keys — NIST, ENISA, and major browsers require at least RSA-2048. Use RSA-3072 or RSA-4096 for certificates and keys that must remain secure beyond 2030.
  2. Use OAEP padding for encryption — RSA-OAEP (Optimal Asymmetric Encryption Padding) is the recommended padding scheme. Never use textbook RSA (no padding) or PKCS#1 v1.5 for new implementations.
  3. Use PSS padding for signatures — RSA-PSS (Probabilistic Signature Scheme) provides a security proof and is preferred over PKCS#1 v1.5 signatures.
  4. Never encrypt large data directly with RSA — RSA can only encrypt data smaller than the key size. Use hybrid encryption: encrypt data with AES, then encrypt the AES key with RSA.
  5. Prepare for post-quantum migration — Shor's algorithm will break RSA when large-scale quantum computers exist. NIST has standardized ML-KEM (Kyber) as a quantum-safe replacement. Begin evaluating hybrid RSA + post-quantum approaches.

ℹ️ Disclaimer

This tool is provided for informational and educational purposes only. All processing happens entirely in your browser - no data is sent to or stored on our servers. While we strive for accuracy, we make no warranties about the completeness or reliability of results. Use at your own discretion.