b2KIT

RSA Key Pair Generator

Generate RSA public/private key pairs using the Web Crypto API with configurable key sizes.

Tested tool guide Tested browser tools Checked August 16, 2026

What RSA Key Pair Generator does, with a checked example

This tool generates an RSA public/private key pair from a key size you choose, using the browser's Web Crypto API rather than a server, so nothing is uploaded and nothing can be intercepted in transit. The primes and exponents come from the browser's own secure random machinery. What surprises most people: generation is deliberately random, so every click produces a different pair, and the private key exists only in the page. Close the tab before saving it and it is gone permanently. The tool creates keys only - it does not encrypt, sign, or issue certificates.

Worked example

A concrete input and expected output from the current implementation.

Input

Key size: 2048 bits

Expected output

-----BEGIN PUBLIC KEY-----
(392 base64 characters encoding the 294-byte SPKI structure; different every run)
-----END PUBLIC KEY-----

-----BEGIN PRIVATE KEY-----
(PKCS#8 encoding of the private key; different every run)
-----END PRIVATE KEY-----

RSA key generation is random by design, so the base64 bodies cannot be predicted and differ on every click; only the envelope is deterministic. Web Crypto exports private keys as PKCS#8 and public keys as SPKI, which is why the headers read PRIVATE KEY and PUBLIC KEY rather than the older PKCS#1 RSA PRIVATE KEY.

How the result is produced

1

How the pair is generated

The page calls the Web Crypto generateKey function with the modulus length you selected, and the browser hunts for two large primes whose product becomes the shared modulus. The public exponent is always 65537, the only value major browsers accept. Prime search is probabilistic and gets slower as keys grow: a 2048-bit pair appears almost instantly, while 4096-bit generation can take a few seconds of CPU time.

2

Formats and export

The generated pair exists in the page as CryptoKey objects. Exporting turns them into PEM text: PKCS#8 for the private key, which begins with BEGIN PRIVATE KEY, and SPKI for the public key, which begins with BEGIN PUBLIC KEY. Because Web Crypto exports PKCS#8, the private key never carries the older PKCS#1 header BEGIN RSA PRIVATE KEY that some legacy tools expect; OpenSSL's rsa command converts between the two formats.

Good uses

  • Building test infrastructure: generating throwaway keys for a local TLS server, a sample JWT signing setup, or a development JWKS without installing OpenSSL.
  • Working on a locked-down or offline machine: everything happens in the page with no network traffic, so key generation still works where package installs and command-line tools are unavailable.
  • Creating your own pair so that others can encrypt to you or verify your signatures: you keep the private half on your machine and share only the public half.

Limits and checks

  • Generation is random, and the page keeps no record of the result. If you navigate away before saving the private key, that pair is gone for good - the tool cannot regenerate it. Save both halves somewhere safe, and remember the private key is the half that must never be shared.
  • Bigger is not automatically better: a 768-bit RSA modulus was factored in 2010, 1024-bit keys are now widely treated as too weak, and current guidance sets 2048 bits as the minimum. Jumping to 4096 multiplies the cost of every key operation without a comparable security gain.
  • Keys are purpose-bound: in Web Crypto, a pair generated as RSA-OAEP encrypts and decrypts, while one generated as RSASSA-PKCS1-v1_5 signs and verifies, and the two cannot be swapped. This page only generates keys - anything downstream that encrypts, signs, or builds a certificate with them is your responsibility.

Common questions

Does the tool or any server see my private key?

No. Generation runs entirely in the browser through the Web Crypto API, and the page makes no network calls, so the private key never leaves your machine unless you copy or download it yourself. The flip side: nobody can recover it for you. If you lose the file or close the tab first, the key is unrecoverable, so back it up somewhere safe.

Why does 4096-bit generation take so long, and is it worth it?

Prime search is probabilistic, and the search space grows with the modulus size, so 4096-bit generation can consume seconds of CPU while 2048-bit is near-instant. The extra size buys a modest margin against future attacks, but 2048-bit remains the accepted baseline; the far more common failure is a lost or shared private key.

References and verification

The example and behavioral notes were checked against the browser implementation. Standards and primary references below define the relevant format, formula, or platform behavior.

Related Tools