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.RSA-OAEP with SHA-256 · PEM output
Generated key pairRSA-2048
Generating your RSA key pair…
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 Size | Security Level | Performance | Use Cases |
|---|---|---|---|
| 1024 bits | Deprecated | Very Fast | Legacy systems only |
| 2048 bits | Current Standard (~112 bits) | Fast | Web browsers, most applications; adequate until ~2030 |
| 4096 bits | High Security (~140 bits) | Moderate | Root CAs, long-term protection |
Implementation Examples
Node.js Encryption
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
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 2048Extract public key
openssl rsa -in private.pem -pubout -out public.pemGenerate with passphrase (more secure)
openssl genrsa -aes256 -out private.pem 4096Generate SSH key pair
ssh-keygen -t rsa -b 4096 -f ~/.ssh/id_rsaHow to use this RSA key generator
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 →