Skip to main content

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 browser

Private key (PKCS#8, PEM) — keep this secret

Stays in your browser

Plain text (max 190 bytes for a 2048-bit key)

Stays in your browser

Shortcuts: 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.

Frequently asked questions

Is my private key ever sent anywhere?
No. Key generation, encryption, and decryption all run locally using your browser's native window.crypto.subtle (Web Crypto API). Nothing — not the private key, not the plaintext — ever leaves your browser.
Why is there a maximum text length for RSA encryption?
RSA-OAEP with a 2048-bit key and SHA-256 can only encrypt up to 190 bytes in a single operation — the padding scheme itself consumes part of the available space, and RSA isn't designed to scale to arbitrary-length data the way a block cipher is. In practice, real systems use RSA only to encrypt a short symmetric key (this is called "key wrapping" or a "hybrid cryptosystem"), then use that symmetric key with AES to encrypt the actual bulk data.
What format are the generated keys in?
The public key is exported as SPKI (SubjectPublicKeyInfo) and the private key as PKCS#8 — both standard, widely-supported DER formats, PEM-encoded (the same base64-with-header/footer format OpenSSL and most TLS tooling produce and accept).
Should I use this to protect real secrets?
This tool is genuinely using your browser's real cryptographic implementation, but treat it as a learning/prototyping tool rather than a production key-management system — a generated private key that's only ever held in a browser tab's memory has no secure, durable storage, backup, or access-control model behind it the way a real key management service would.
Can I use the generated key pair to sign things, like a JWT or a Git commit?
Yes, if you choose a signing purpose before generating: RS256 (RSASSA-PKCS1-v1_5, the common JWT algorithm) or PS256 (RSA-PSS). Keys made for encryption are not the same as keys made for signing, so pick the purpose first. The Sign and Verify modes below use them, and the OpenSSH public key line can go into authorized_keys.
What is the difference between an RSA public and private key?
The two keys are a pair. The public key can be given to anyone: it encrypts data for you or checks your signatures. The private key must stay secret: it decrypts what was encrypted for you and creates signatures. If the private key leaks, anyone can read your messages and sign as you.

Related tools

More Security & Auth

View all Security & Auth tools →