RandomKeygen
Free · Private · Client-sideGenerated locally — never transmitted

RSA Key Pair Generator

Generate RSA public and private key pairs for asymmetric encryption, digital signatures, and secure key exchange. Create industry-standard RSA keys compatible with OpenSSL, SSH, TLS/SSL, and legacy cryptographic applications.

Algorithm

RSA-OAEP with SHA-256 · PEM output

Generated key pairRSA-4096

Generating your RSA key pair…

RSA-4096 ≈ 140-bit classical security — strongest classical RSA fallback; not quantum-resistant.

What is RSA Encryption?

RSA (Rivest-Shamir-Adleman) is one of the most widely used public-key cryptosystems for secure data transmission. Named after its inventors Ron Rivest, Adi Shamir, and Leonard Adleman, RSA enables secure communication without requiring a shared secret key.

Asymmetric Encryption

Uses a pair of mathematically related keys: one public (shareable) and one private (secret). Data encrypted with one key can only be decrypted with the other.

Digital Signatures

Sign documents and messages with your private key to prove authenticity and integrity. Others can verify signatures using your public key.

Key Exchange

Securely share symmetric encryption keys over insecure channels. Commonly used in TLS/SSL handshakes and secure communication protocols.

Common Use Cases

Encryption

Encrypt sensitive data with the public key. Only the private key holder can decrypt it.

Digital Signatures

Sign documents or code with your private key. Anyone can verify with your public key.

JWT Signing (RS256)

Sign JWTs with RSA for scenarios where multiple parties need to verify tokens.

Key Exchange

Securely exchange symmetric keys by encrypting them with the recipient’s public key.

RSA Key Size Comparison

Key SizeSecurity LevelPerformanceUse Cases
1024 bitsDeprecatedVery FastLegacy systems only
2048 bitsLegacy (~112-bit classical)FastLegacy systems only; actively being phased out
3072 bitsTransitional (~128-bit classical)ModerateCNSA 1.0 classical floor during PQC transition
4096 bitsStrong Classical (~140-bit)SlowerBest classical fallback; still vulnerable to quantum attacks
ML-KEM-1024 / ML-DSA-87Post-Quantum (CNSA 2.0)Very FastTarget replacement for new systems — ML-KEM & ML-DSA

Implementation Examples

Node.js Encryption

rsa-encrypt.js
const crypto = require('crypto');
const fs = require('fs');

// Load RSA keys
const publicKey = fs.readFileSync('public.pem', 'utf8');
const privateKey = fs.readFileSync('private.pem', 'utf8');

// Encrypt data
function encryptRSA(data, publicKey) {
  return crypto.publicEncrypt({
    key: publicKey,
    padding: crypto.constants.RSA_PKCS1_OAEP_PADDING,
    oaepHash: 'sha256',
  }, Buffer.from(data));
}

// Decrypt data
function decryptRSA(encryptedData, privateKey) {
  return crypto.privateDecrypt({
    key: privateKey,
    padding: crypto.constants.RSA_PKCS1_OAEP_PADDING,
    oaepHash: 'sha256',
  }, encryptedData);
}

const message = "Hello, RSA!";
const encrypted = encryptRSA(message, publicKey);
const decrypted = decryptRSA(encrypted, privateKey);
console.log('Decrypted:', decrypted.toString());

Python Digital Signatures

rsa-sign.py
from cryptography.hazmat.primitives import hashes, serialization
from cryptography.hazmat.primitives.asymmetric import rsa, padding

# Generate key pair
private_key = rsa.generate_private_key(
    public_exponent=65537, key_size=2048
)
public_key = private_key.public_key()

# Sign data
def sign_data(data, private_key):
    return private_key.sign(
        data.encode('utf-8'),
        padding.PSS(
            mgf=padding.MGF1(hashes.SHA256()),
            salt_length=padding.PSS.MAX_LENGTH
        ),
        hashes.SHA256()
    )

# Verify signature
def verify_signature(data, signature, public_key):
    try:
        public_key.verify(
            signature, data.encode('utf-8'),
            padding.PSS(
                mgf=padding.MGF1(hashes.SHA256()),
                salt_length=padding.PSS.MAX_LENGTH
            ), hashes.SHA256()
        )
        return True
    except:
        return False

message = "Important document"
signature = sign_data(message, private_key)
is_valid = verify_signature(message, signature, public_key)
print(f"Valid signature: {is_valid}")

RSA Applications

Web Security

  • TLS/SSL Certificates: HTTPS connections
  • JWT Signing: RS256 algorithm
  • OAuth: API authentication
  • Code Signing: Software verification

Communication

  • Email Encryption: S/MIME
  • PGP/GPG: File encryption
  • VPN: IPsec configurations
  • Messaging: End-to-end encryption

Web Push notifications use ECDSA P-256 key pairs rather than RSA — generate VAPID keys for those instead.

Generate Locally (Recommended)

For production use, generate RSA keys locally:

Generate 4096-bit RSA private key (OpenSSL)

$openssl genrsa -out private.pem 4096

Extract public key

$openssl rsa -in private.pem -pubout -out public.pem

Generate with AES-256 passphrase protection

$openssl genrsa -aes256 -out private.pem 4096

Post-quantum alternative (OpenSSL 3.5+ · CNSA 2.0)

$openssl genpkey -algorithm ML-KEM-1024 -out mlkem1024.pem

How to use this RSA key generator

01
Choose a key size
Use 4096 bits (default) or at least 3072 bits for classical compatibility. Only pick 2048 bits when a legacy system requires it—and migrate new long-lived systems to ML-KEM or ML-DSA.
02
Generate and copy each key
The public key is safe to share — use it to encrypt data or verify signatures. Copy each PEM block with its own button.
03
Protect the private key
Store the private key in a secrets manager or encrypted file, never in source control. For production, generate locally with OpenSSL.

Post-quantum & production notice

RSA is a classical public-key algorithm vulnerable to future quantum attacks (Shor's algorithm) and harvest-now, decrypt-later collection. Following the NSA's Dec 2026 CNSA 2.0 advisory, use RSA-3072/4096 only as a transitional fallback—for new key exchange or signing systems, use ML-KEM (FIPS 203) or ML-DSA (FIPS 204).

While these keys are generated locally in your browser and never transmitted, for production use generate keys on your own machine with OpenSSL and never share your private key.

Read the post-quantum cryptography guide →