🔑 RSA Key Pair Generator – Browser-Based Asymmetric Key Tool
The RSA Key Pair Generator lets you create RSA public/private key pairs entirely in your browser using the Web Crypto API. No data is ever sent to a server — your private key is generated and stays on your device. It supports key sizes from 1024 to 4096 bits and exports keys in PEM, DER (Base64), and JWK formats, making it suitable for TLS, SSH, JWT signing, API authentication, and educational use.
What is RSA?
RSA (Rivest–Shamir–Adleman) is the most widely deployed asymmetric (public-key) cryptographic algorithm. It generates a mathematically linked key pair: a public key that anyone can use to encrypt data or verify signatures, and a private key that only the owner possesses to decrypt or sign. The security of RSA relies on the computational difficulty of factoring the product of two large prime numbers — a problem that remains infeasible for sufficiently large keys with current technology.
Key Size Guide
Choosing the right key size balances security strength against performance. Larger keys are stronger but slower to generate and use in cryptographic operations.
| Key Size | Security Level | Recommended Use |
|---|---|---|
1024 bits | ⚠️ Deprecated | Demo and testing only — do not use in production |
2048 bits | ✅ Standard | General TLS, JWT signing, SSH keys (valid until ~2030) |
3072 bits | ✅ Strong | High-security applications, certificates with long lifespans |
4096 bits | 🔒 Maximum | Root CAs, PGP master keys, long-term data protection |
Output Formats Explained
PEM (Privacy Enhanced Mail)
PEM is the most widely supported format. It encodes the DER binary data as Base64 and wraps it with a human-readable ASCII header and footer such as -----BEGIN PUBLIC KEY-----. PEM files are used by OpenSSL, Nginx, Apache, Node.js, and most other TLS/SSL tooling. This tool supports both the modern PKCS#8 format (-----BEGIN PRIVATE KEY-----) and the legacy PKCS#1 format (-----BEGIN RSA PRIVATE KEY-----).
The two are different structures, not just different headers. PKCS#8 is a PrivateKeyInfo wrapper that names the algorithm (rsaEncryption) and carries the key inside an OCTET STRING. That inner value is the PKCS#1 RSAPrivateKey (modulus, exponents, primes and CRT values). When you pick PKCS#1, the tool extracts that inner structure, so the file opens with openssl rsa -in key.pem -check and with older libraries that only understand the RSA-specific format.
DER (Base64 Raw)
DER is the binary ASN.1 representation of the key structure. This tool displays DER bytes as a Base64 string for easy copying and use in environments that consume raw DER, such as Java keystores, Android Keystore, or .NET certificate APIs.
JWK (JSON Web Key)
JWK represents the key as a JSON object with fields like kty, n (modulus), and e (public exponent). JWK is used in OAuth 2.0 / OIDC JWKS endpoints, Web Crypto API operations, and modern JavaScript/TypeScript cryptographic libraries. The private JWK additionally includes d, p, q, dp, dq, and qi components.
Passphrase-Protected Private Keys
When you provide a passphrase (PEM or DER output), the private key is saved as a standard PKCS#8 EncryptedPrivateKeyInfo (RFC 5958), shown in PEM as -----BEGIN ENCRYPTED PRIVATE KEY-----. It uses the PKCS#5 v2.1 PBES2 scheme: an AES-256 key is derived from your passphrase with PBKDF2-HMAC-SHA256 (600,000 iterations, random 16-byte salt), and the PKCS#8 key is encrypted with AES-256-CBC under a random 16-byte IV. The salt, iteration count and IV are recorded in the file's algorithm parameters, so OpenSSL, Node.js, Java and most TLS servers can decrypt it with the passphrase alone:
openssl pkey -in private_key.pem -passin pass:YOUR_PASSPHRASE -noout
openssl pkey -in private_key.pem -out private_key_plain.pem # remove the passphraseAn encrypted key is always PKCS#8, even if you selected the PKCS#1 structure: the legacy encrypted PKCS#1 format relies on MD5-based key derivation and is not offered. JWK output is never encrypted. Always use a strong, unique passphrase for any key you plan to store or share.
SHA-256 Public Key Fingerprint
The SHA-256 fingerprint is computed by hashing the raw DER bytes of the public key (SPKI format) with SHA-256 and displaying the result as colon-separated uppercase hexadecimal pairs — for example 3A:F2:...:9B. Fingerprints let you quickly verify that two representations of the same key (e.g., a JWK and a PEM) belong to the same key pair without comparing the full key text.
Common Use Cases
- JWT RS256 / RS512 signing: Generate a key pair, use the private key to sign tokens and the public key to verify them.
- TLS/SSL certificate generation: Create a CSR (Certificate Signing Request) with your private key and share the public key with a CA.
- SSH authentication: OpenSSH expects its own key formats, so use the SSH Key Generator for
~/.ssh/authorized_keysentries, or convert the PEM public key withssh-keygen -i -m PKCS8 -f public_key.pem. - API authentication: Use RSA key pairs for service-to-service authentication in OAuth 2.0 client credential flows with
private_key_jwt. - Education and testing: Explore RSA key structure, test cryptographic libraries, or create throwaway keys for local development environments.
How the Web Crypto API is Used
This tool calls crypto.subtle.generateKey() with the RSA-OAEP algorithm descriptor specifying the modulus length, public exponent 65537, and the chosen hash algorithm. The resulting CryptoKeyPair is exported using crypto.subtle.exportKey() in spki format (public key) and pkcs8 format (private key). All operations are asynchronous and non-blocking, which is why key generation on larger sizes like 4096 bits may take a few seconds.
The public exponent is fixed at 65537 (0x10001) — a Fermat prime that provides strong security properties and fast public-key operations. It is the standard choice in virtually all real-world RSA implementations.