RSA Key Pair Generator & Encryption
Free RSA key generator: make 2048-bit key pairs, then encrypt, decrypt, sign and verify. Runs in your browser; keys are never uploaded.
RSA key pair
Public key (SPKI, PEM)
Stays in your browserPrivate key (PKCS#8, PEM) — keep this secret
Stays in your browserPlain text (max 190 bytes for a 2048-bit key)
Stays in your browserShortcuts: Ctrl+Enter run · Ctrl+Shift+C copy result · / search (use ⌘ on Mac)
Free Online RSA Key Pair Generator & Encryption Tool
Generate a 2048, 3072 or 4096-bit RSA public/private key pair, then encrypt short text with the public key and decrypt it with the private key, or sign and verify text — key generation and every cryptographic operation run locally via your browser's Web Crypto API. Use this RSA key generator to make a key pair and try RSA encryption and signing. It helps developers experiment with public-key encryption, key pairs, and PEM output before integrating a real certificate or key-management workflow.
How RSA public-key encryption works
Unlike AES, RSA is asymmetric: it uses two mathematically related keys instead of one shared secret. Anything encrypted with the public key can only be decrypted with the matching private key — which means the public key can be shared freely (even published), while only the private key needs to stay secret. This tool generates a 2048, 3072 or 4096-bit RSA key pair (RSA-OAEP with SHA-256 for encryption, RS256 or PS256 for signing), exports the public key as SPKI and the private key as PKCS#8 (both standard PEM formats), and lets you try an encrypt/decrypt round trip directly in the browser.
Why there's a text length limit
RSA-OAEP isn't a general-purpose bulk cipher — with a 2048-bit key and SHA-256, the maximum plaintext per operation is 190 bytes, dictated by the key size minus the OAEP padding overhead. Real-world systems handle this by combining RSA with AES in a hybrid cryptosystem: generate a random AES key, encrypt the actual (arbitrarily large) data with AES, then use RSA only to encrypt that short AES key so it can be safely shared with the key pair's owner. TLS and most secure messaging protocols work this way.
Why Base64 encoding is not encryption
Worth repeating here too: the ciphertext this tool outputs is displayed as Base64 purely so it's easy to copy and paste, not because Base64 itself provides any security. Base64 has no key and is trivially reversible by anyone — the actual confidentiality comes entirely from the RSA encryption step performed before that encoding. If you only Base64-encode text and skip the RSA (or AES) step, you have not encrypted anything.
How to use this tool
Click Generate Key Pair to create a fresh public and private key (or paste your own PEM-formatted keys into the fields). Switch to Encrypt, enter text under the length limit above, and encrypt it with the public key. Switch to Decrypt, paste the Base64 ciphertext, and decrypt it with the matching private key.
Worked example
With a 2048-bit key, exactly 190 bytes of plaintext encrypts successfully; 191 bytes fails with the length-limit error above — confirmed by testing both boundaries against the real Web Crypto implementation. Unlike AES-CBC's small chance of "succeeding" with garbage on a wrong key, decrypting RSA-OAEP ciphertext with an unrelated private key reliably fails every time — also seen in testing — since OAEP's padding check is far stricter than CBC's.
Common mistakes and edge cases
- Pasting the private key into the public key field (or vice versa) fails to encrypt/decrypt, since SPKI and PKCS#8 are structurally different formats — the error message doesn't specifically say "wrong key type," just that the key is invalid, so double-check which field you pasted into.
- A key made for encryption cannot be used for signing and the other way round. Choose “Use for” before you generate.
- Generating a new key pair replaces both fields immediately, discarding whatever was there — copy out a key pair you want to keep before clicking Generate again.