RSA Key Pair Generator
Generate RSA public and private key pairs in your browser
Default: 2048 bits
How to use
About this tool
Generates RSA public and private key pairs in the browser. A 2048-bit key pair is automatically generated when you open the page, and you can regenerate with a different key length. Generated keys are displayed in PEM format and can be copied or downloaded.
How to use
1. When you open the page, a key pair is automatically generated with the default (2048 bits), and the public and private keys are displayed. 2. To change key length: Enter a value that is a multiple of 8 between 512 and 8192 bits in the key length field, then click "Generate". 3. To generate a new key pair with the same key length: Click the "Regenerate" button. 4. Copy keys: Click the copy button in each key's display area to copy to the clipboard. 5. Download keys: Click the download button in each key's display area to download as a PEM file (public key: public_key.pem, private key: private_key.pem).
Options
Key length: Must be between 512 and 8192 bits and a multiple of 8. Default is 2048 bits. Use the up/down buttons in the number input to increment/decrement by 8. Invalid values (out of range or not a multiple of 8) show an error message and disable the "Generate" and "Regenerate" buttons.
Use cases
• Generating key pairs for SSH connections (public key authentication setup) • Creating private keys for SSL/TLS certificates • Generating key pairs for JWT signing • Creating key pairs for encrypted communication • Temporary key pair generation for development and testing • Generating key pairs for code signing
Code Examples
1// Generate key pair
2const keyPair = await window.crypto.subtle.generateKey(
3 {
4 name: 'RSA-OAEP',
5 modulusLength: 2048,
6 publicExponent: new Uint8Array([1, 0, 1]), // 65537
7 hash: 'SHA-256',
8 },
9 true, // extractable
10 ['encrypt', 'decrypt']
11);1from cryptography.hazmat.primitives.asymmetric import rsa
2from cryptography.hazmat.primitives import serialization
3
4# Generate key pair
5private_key = rsa.generate_private_key(
6 public_exponent=65537,
7 key_size=2048
8)
9public_key = private_key.public_key()
10
11# Export in PEM format
12private_pem = private_key.private_bytes(
13 encoding=serialization.Encoding.PEM,
14 format=serialization.PrivateFormat.PKCS8,
15 encryption_algorithm=serialization.NoEncryption()
16)
17public_pem = public_key.public_bytes(
18 encoding=serialization.Encoding.PEM,
19 format=serialization.PublicFormat.SubjectPublicKeyInfo
20)1# Generate 2048-bit RSA private key
2openssl genrsa -out private_key.pem 2048
3
4# Extract public key
5openssl rsa -in private_key.pem -pubout -out public_key.pemHow it works
RSA key pair generation prioritizes the Web Crypto API. If Web Crypto API is unavailable or PEM conversion fails, it falls back to the node-forge library. Generated keys are displayed in PEM format (public key: -----BEGIN PUBLIC KEY-----, private key: -----BEGIN PRIVATE KEY-----). Larger key lengths take longer to generate, but a 2048-bit key pair typically completes within 5 seconds. All processing is done in the browser; keys are never sent to any server.
Privacy and data
All key generation is done in the browser; generated public and private keys are never sent to any server. Keys exist only in browser memory and are not automatically saved. Private keys are sensitive information; manage them appropriately and clear them from memory (e.g., by closing the browser) when no longer needed.
