RSA Key Pair Generator
Generate RSA key pairs and export as PEM. Inspect existing keys. Uses Web Crypto API — your keys never leave the browser.
How to Generate an RSA Key Pair
- Choose key size: 2048 bits is standard; 4096 bits for higher security (note: takes longer to generate).
- Click "Generate Key Pair." The browser uses its secure random number generator and Web Crypto API.
- Download or copy the private key (keep this secret!) and the public key (share freely).
- Inspect mode: paste any PEM public or private key to view its algorithm, key size, and other properties.
About RSA Encryption
RSA (Rivest–Shamir–Adleman) is the most widely used asymmetric encryption algorithm, invented in 1977. It is based on the computational difficulty of factoring the product of two large prime numbers. The public key contains the modulus n (the product of two primes) and a public exponent e (usually 65537). The private key contains the modulus and the private exponent d, which can only be computed if you know the prime factors.
RSA-OAEP vs. RSA-PKCS1v15
This tool generates keys with the RSA-OAEP (Optimal Asymmetric Encryption Padding) scheme, which is the modern, secure standard. The older PKCS1v15 padding scheme is vulnerable to padding oracle attacks (the Bleichenbacher attack) and should not be used in new systems. RSA-OAEP uses random padding with SHA-256 as the hash function, preventing these attacks. The Web Crypto API only supports RSA-OAEP for encryption, which is the right choice.
PEM Format Explained
PEM (Privacy Enhanced Mail) is the most common format for storing cryptographic keys and certificates. A PEM file is a Base64-encoded representation of DER (Distinguished Encoding Rules) binary data, wrapped with header and footer lines like -----BEGIN PRIVATE KEY-----. The format was originally developed for email but became the universal standard for TLS certificates, SSH keys, and code signing certificates. PEM files are plain text and can be opened with any text editor — though you should never share private key PEM files.
Private Key Security
An RSA private key is the most sensitive file in a cryptographic system. Anyone with your private key can decrypt any data encrypted with your public key and forge signatures in your name. Store private keys securely: use OS keychain storage, encrypted key files (PKCS#12 / .p12 format), or hardware security modules (HSMs) for production use. For development keys, at minimum use filesystem permissions to restrict access. For comparison, see our AES Encryption tool for symmetric key use cases and JWT Decoder for working with JWTs that use RSA signing.
When to Use RSA vs. ECDSA
RSA is the most compatible asymmetric algorithm — every TLS library, operating system, and programming language supports it. However, Elliptic Curve Cryptography (ECDSA/Ed25519) offers equivalent security with much smaller key sizes and faster operations. A 256-bit ECDSA key provides the same security as a 3072-bit RSA key. For new systems where all parties control the implementation (APIs, microservices), ECDSA (P-256) or Ed25519 are better choices. For maximum compatibility with legacy systems (enterprise PKI, old SSH clients), RSA 2048/4096 remains necessary.