RSA Key Pair Generator

Crypto

Generate RSA key pairs locally with Web Crypto and export both as PEM at 2048/3072/4096 bits. Private key is PKCS#8, public key SPKI, ready for openssl or TLS.

Ready
Public key
—
Private key
—

About RSA Key Pair Generator

RSA is the classic asymmetric algorithm: in a key pair the public key encrypts or verifies while the private key decrypts or signs, used widely in HTTPS certificates, SSH, and JWT RS256. This tool generates an RSA key pair locally with the browser's Web Crypto API, with selectable 2048/3072/4096-bit length, and outputs standard PEM (SPKI public key, PKCS#8 private key) ready to paste into config or code. For example, choosing 2048 bits generates a PEM private/public key pair for signing, verification or SSH key testing. The whole point of an asymmetric key pair is that the public half can be handed out freely: sign with the private key and anyone can verify with the public one, encrypt with the public key and only the private key holder can read it. That asymmetry removes the need for a secure channel to distribute keys, at the cost of being far slower than symmetric encryption, which is why real systems normally use it to negotiate or wrap a symmetric key and let that key handle the data. Generation picks two large primes and derives a related pair of large integers, publishing one together with the modulus while the other must stay strictly secret. Key length sets the strength, and current practice starts at 2048 bits with 4096 for long-lived or high-value use. Longer keys increase generation time noticeably and slow signing more than verification, which is the trade-off to weigh when choosing. Practical notes: Generate private keys in a trusted environment; a key generated in the browser never leaves the machine, but that also means losing it is unrecoverable, so back it up immediately. Private key files come in several formats, the classic one being widely compatible but unencrypted by default and the newer general-purpose one carrying more parameters. Protect the private key with a passphrase on export and never store the key and its passphrase in the same place. Public keys can be distributed freely but should be published through a trusted channel and periodically reconciled with what production actually uses, or nothing stops a substitution. Limits: Asymmetric keys have boundaries: they are not for encrypting bulk data, and they are the wrong tool for storing passwords, which need a work-factor hash. Key length is also not the whole of security, since implementation flaws and randomness quality matter just as much, and an unreliable random source makes keys predictable, so generation must come from a trusted one. Older algorithm families have been shown unfit for continued use, so new systems should pick the currently recommended padding and parameters and confirm that library defaults have kept pace with releases. Data and privacy: this tool produces genuinely usable key material, the most sensitive data of the group. Generation and export happen entirely in the browser with nothing uploaded, so it works offline; even so, production keys are better generated in a dedicated offline environment and immediately backed up and registered per your key management policy.

How It Works Internally

Generation picks two large primes and derives a related pair of large integers: one is published with the modulus, the other must stay secret. Security rests on the assumption that deriving the private key from the public key and modulus is equivalent to factoring a large integer, so key length sets strength directly; longer keys take noticeably longer to generate and slow signing more than verification. Older padding schemes are unfit for continued use.

Length and cost
InputGenerate a 4096-bit key pair
OutputGeneration takes several times longer than 2048 bits and signing slows more than verification, which is why 4096 bits suit long-lived keys

Measured on This Page

OpenSSL end to endPrivate key self-test passed · public key re-exported from the private key matches · sign and verify both passed
Key sizes2048 / 3072 / 4096 (the page text said 1024/2048/4096, which never matched the buttons; corrected)
PEM formatPrivate key PKCS#8 (BEGIN PRIVATE KEY), public key SPKI (BEGIN PUBLIC KEY)
Google, last 90 days4 clicks / 50 impressions / average position 23.5

The PEM header decides whether the key can be used at all: BEGIN RSA PRIVATE KEY is the older PKCS#1 layout while BEGIN PRIVATE KEY is PKCS#8 — this page exports the latter, which OpenSSL and mainstream SDKs accept. When a server reports no start line or unsupported key format, compare those two header lines before regenerating anything.

How this was measured: Clicked generate to produce a key pair with WebCrypto, copied both PEM text areas to local files and ran four OpenSSL 3.5.7 checks: private key self-test, re-export the public key from the private key and compare, SHA-256 sign, then verify with the exported public key. · Measured 2026-10-28

How to Use

  1. Open "RSA Key Pair Generator"
  2. Pick a 2048-, 3072- or 4096-bit key size
  3. Click "Generate keys" and wait for the prime search
  4. Copy or download the public key as public.pem
  5. Store private.pem separately, away from chat and repos

Use Cases

  • Generate test key pairs — Quickly produce an RSA PEM pair for a local sign/verify flow under development.
  • Configure JWT RS256 — Create the pair to sign JWTs with the private key and verify with the public key while debugging auth.
  • Learn asymmetric crypto — Follow public-key encryption and private-key decryption to understand how RSA works.
  • Prepare a JWKS — Convert the public key to JWK to build an OIDC public-key endpoint.
  • Validate key format — Check whether an existing PEM is a valid SPKI/PKCS#8 structure.
  • SSH key bootstrap — Generate an RSA pair and paste the public key into a server's authorized_keys for SSH access.
  • Self-signed TLS cert — Create an RSA key pair to use as the foundation for a self-signed TLS certificate for local development.

FAQ

Should I pick 2048 or 4096 bits?

2048-bit is still considered secure and faster, the default for most cases; choose 3072/4096 for long-term confidentiality, but longer keys make signing and verifying slower, so weigh the trade-off.

What are SPKI and PKCS#8?

They are key encodings. This tool emits the public key as SPKI (PEM BEGIN PUBLIC KEY) and the private key as PKCS#8 (BEGIN PRIVATE KEY), the standard formats modern libraries use.

Can RSA encrypt large files directly?

No. RSA can encrypt only data smaller than the key size in one shot. In practice you RSA-encrypt a random AES key and use AES for the bulk data, known as hybrid encryption.

Can public and private keys swap roles?

Not freely. The public key encrypts and verifies; the private key decrypts and signs. The public key can be shared, while the private key must stay secret, since a leak destroys all security.

Is generating production keys in a browser safe?

crypto.subtle's randomness itself is reliable, but the browser may carry extension or script risks. Generate critical production keys on an isolated server; this tool suits development and testing better.

Does a private key file need passphrase protection?

Yes. An unencrypted private key can be used the moment it is copied, which is equivalent to handing over the identity, whereas a passphrase means a leaked file still has to be cracked. Keep the key and its passphrase in separate places or the protection is nominal. On export, confirm the format supports a passphrase and verify that another tool really prompts for it.

Key generation hangs for a long time. Is something wrong?

No. Longer keys mean more computation to find large primes, and 4096 bits takes noticeably longer than 2048 on ordinary hardware, especially in a browser. Do not refresh the page or the generation is interrupted. If you generate keys often, do it on the command line and store the result carefully; a browser is better suited to learning and checking parameters.

Can the generated RSA key pair be used directly for an HTTPS certificate?

The pair is key material only; a certificate still needs CSR → CA signing. You can generate a CSR from this key. Use at least 2048 bits (4096 is safer but slower for signing and handshakes); self-signed works but browsers will warn.