Free · Private · Client-side

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 cryptographic applications.

Generated values never leave this device.
Algorithm

RSA-OAEP with SHA-256 · PEM output

Generated key pairRSA-2048

Generating your RSA key pair…

RSA-2048 ≈ 112-bit symmetric security — the current standard, adequate until ~2030.

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 bitsCurrent Standard (~112 bits)FastWeb browsers, most applications; adequate until ~2030
4096 bitsHigh Security (~140 bits)ModerateRoot CAs, long-term protection

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

Generate Locally (Recommended)

For production use, generate RSA keys locally:

Generate private key (OpenSSL)

$openssl genrsa -out private.pem 2048

Extract public key

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

Generate with passphrase (more secure)

$openssl genrsa -aes256 -out private.pem 4096

Generate SSH key pair

$ssh-keygen -t rsa -b 4096 -f ~/.ssh/id_rsa

How to use this RSA key generator

01
Choose a key size
2048 bits is the current standard for general use; pick 4096 bits for long-term or high-security keys.
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.

Security notice

While these keys are generated securely in your browser and never transmitted, for production use you should generate keys locally using OpenSSL or your operating system's tools. Never share your private key or transmit it over the network.

How public-key encryption works →