RSA Key Pair Generator

Generate RSA public & private keys in your browser using the WebCrypto API. Nothing leaves your device.

How it works: Keys are generated using the browser's built-in WebCrypto API (window.crypto.subtle.generateKey). The private key never leaves your browser β€” no network requests, no server, no logging. The exported PEM format is compatible with OpenSSL, Node.js, Python's cryptography library, and most TLS/SSH tooling.

2048-bit is standard for most uses. 4096-bit takes a few seconds to generate but provides a larger security margin.

What is RSA Key Generator?

RSA Key Generator creates RSA public/private key pairs in your browser β€” no data is sent to any server. Choose the key size (2048, 3072, or 4096 bits), and generate the key pair in PEM format (PKCS#8 private key and SPKI public key). It also converts between key formats (PEM, DER, JWK) and shows the key's components (modulus, exponents, prime factors) for inspection.

RSA (Rivest-Shamir-Adleman) is an asymmetric cryptography algorithm using a mathematically linked key pair: anything encrypted with the public key can only be decrypted with the private key, and vice versa. RSA is used for: TLS/SSL certificate signatures, SSH public key authentication, JWT RS256/RS384/RS512 signing, code signing, and email encryption (PGP/GPG). The private key must be kept secret; the public key is shared freely.

Key size recommendations: 2048-bit (minimum acceptable, but aging), 3072-bit (recommended for new implementations, equivalent security to 128-bit AES), 4096-bit (strong, slower β€” adds ~100ms to TLS handshakes). NIST recommends 2048-bit through 2030 and 3072-bit after that. RSA is being superseded in many use cases by elliptic curve cryptography (ECDSA with P-256/P-384 or Ed25519) which provides equivalent security with much smaller key sizes.

How to Use

  1. Select the key size: 2048-bit (fast), 3072-bit (balanced), or 4096-bit (strongest, slowest).
  2. Click 'Generate Key Pair' β€” key generation happens in your browser using the Web Crypto API.
  3. Copy the private key (PEM format) and store it securely β€” never share it.
  4. Copy the public key (PEM format) and distribute it to services that need to verify your signatures.
  5. Use 'Convert format' to switch between PEM, DER, or JWK format for your key.

Examples

Generate SSH keypair

Result: 4096-bit RSA β†’ private key for ~/.ssh/id_rsa + public key for authorized_keys

JWT RS256 signing

Result: 2048-bit RSA β†’ private key signs JWT, public key published at /.well-known/jwks.json

Self-signed certificate

Result: Generate key pair β†’ use with openssl to create a self-signed certificate for local dev

Frequently Asked Questions

What is the difference between RSA and ECDSA for TLS?

RSA: mathematically based on integer factorization, mature, widely supported, large key sizes (2048+ bits) needed for security. ECDSA: elliptic curve discrete logarithm, newer, much smaller keys (256-bit ECDSA β‰ˆ 3072-bit RSA security), faster operations, smaller TLS handshake data. ECDSA P-256 (secp256r1) is now the preferred choice for TLS certificates β€” it's supported by all modern browsers and provides better performance than 2048-bit RSA. Ed25519 is even faster and is the recommended SSH key type.

How do I generate an RSA key pair on the command line?

OpenSSL: openssl genrsa -out private.pem 2048 (generate private key) then openssl rsa -in private.pem -pubout -out public.pem (extract public key). SSH keygen: ssh-keygen -t rsa -b 4096 -C 'your@email.com' (generates ~/.ssh/id_rsa and id_rsa.pub). Node.js: crypto.generateKeyPairSync('rsa', { modulusLength: 2048, publicKeyEncoding: {type:'spki', format:'pem'}, privateKeyEncoding: {type:'pkcs8', format:'pem'} }).

How should I store a private key securely?

Private keys must be protected: (1) File system: restrict permissions to 600 (rw-------), owned by the user, not in a web-accessible directory. (2) Encrypt with a passphrase: openssl genrsa -aes256 -passout pass:mypassphrase -out private.pem 2048. (3) Hardware Security Modules (HSM) or TPM: store the key in tamper-resistant hardware for highest security. (4) Key management services: AWS KMS, HashiCorp Vault, Azure Key Vault store keys server-side and perform cryptographic operations without exposing the key.

What is PKCS#8 and PKCS#1 format?

Both are PEM formats for RSA private keys. PKCS#1 (RSAPrivateKey) starts with -----BEGIN RSA PRIVATE KEY----- and contains only RSA-specific key material. PKCS#8 (PrivateKeyInfo) starts with -----BEGIN PRIVATE KEY----- and includes an algorithm identifier β€” it's algorithm-agnostic and can store RSA, ECDSA, or Ed25519 keys. Modern systems prefer PKCS#8 for its flexibility. Java and many modern tools generate PKCS#8 by default. OpenSSL's RSA subcommand generates PKCS#1; the genpkey subcommand generates PKCS#8.

What is JWK (JSON Web Key) format?

JWK (JSON Web Key) is a JSON representation of cryptographic keys, defined by RFC 7517. A JWK set (JWKS) is an array of JWKs, typically published at /.well-known/jwks.json for public key discovery. Example: {"kty":"RSA","n":"...","e":"AQAB","use":"sig","kid":"key-1"}. JWK is the standard format for OAuth2/OIDC public key endpoints and JWT libraries that fetch public keys for token verification. This is how your Authorization Server's public keys are shared with Resource Servers.

Related Tools