RSA Key Pair Generator

Keys are generated locally using your browser's Web Crypto API and never leave your device. Reload the page to discard them.

How to use this RSA key pair generator

  1. Choose a key size (2048-bit is standard, 4096-bit is more secure but slower).
  2. Click "Generate Pair".
  3. Copy the public key to share, and keep the private key secret.

How does this work?

Keys are generated using your browser's native Web Crypto API (crypto.subtle.generateKey), the same cryptographic engine used by browsers for TLS — nothing is sent to any server, and the keys exist only in your browser's memory.

Is it safe to generate a private key in a browser?

The Web Crypto API is a well-audited, standard browser feature — the generation itself is sound. Just be sure to close this tab and clear your clipboard once you've saved the keys somewhere secure, since nothing here persists after a reload.

Should I use 2048 or 4096 bits?

2048-bit is still considered secure for most use cases through the foreseeable future and is faster to generate and use. 4096-bit offers a larger security margin at the cost of speed, useful for long-term or highly sensitive keys.

The math behind why RSA is hard to break

RSA's security rests on a specific, well-studied mathematical asymmetry: multiplying two large prime numbers together is computationally easy, but factoring the resulting product back into those two original primes is extraordinarily hard once the numbers are large enough. An RSA public key is built from this product (called the modulus) along with a public exponent; the private key encodes the same modulus along with a value derived from the two original primes, which is only computable if you actually know what those primes were. Breaking RSA by brute-force factoring the modulus back into its prime components is theoretically always possible, but for a properly sized key, it would take far longer than the age of the universe with any classical computing approach known today — the entire security model depends on factoring staying computationally infeasible at scale, not on it being impossible in principle.

Why key size matters so much, and why it isn't a linear scale

Going from a 2048-bit key to a 4096-bit key doesn't double the security margin — the difficulty of factoring grows much faster than linearly with key size, since the best known factoring algorithms have a complexity that scales in a way where each additional bit meaningfully increases the computational work required, well beyond a simple proportional increase. 2048-bit RSA is still considered adequate for most current uses and is the widely deployed industry standard, but security guidance has been gradually shifting: some organizations and standards bodies have started recommending or requiring 3072-bit or larger keys for systems that need security guarantees over a longer time horizon, since keys generated today may still need to resist attacks using computing power available years or decades from now.

What PEM format actually is, and why keys look that way

The PEM format wrapping these keys — recognizable by its "-----BEGIN...-----" and "-----END...-----" header and footer lines — is simply a way of representing binary cryptographic data as printable ASCII text, using Base64 encoding for the actual key material sandwiched between those delimiter lines. This format exists because raw binary key data is awkward to copy, paste, email, or store in text-based configuration files and source code, while a PEM-wrapped key is just ordinary text that survives being pasted into almost any context without corruption. The header line also identifies what kind of key or certificate the block contains (a public key, a private key, a certificate), which is why software reading a PEM file can immediately tell what it's dealing with before even decoding the Base64 content.

The quantum computing asterisk on RSA's long-term security

RSA's security relies specifically on factoring being hard for classical computers, but a sufficiently large, fault-tolerant quantum computer running an algorithm called Shor's algorithm could factor RSA's modulus efficiently, breaking the underlying assumption entirely. No quantum computer with anywhere near the scale needed to threaten real-world RSA key sizes exists today, and estimates for when (or if) one will vary widely among experts, but this theoretical threat is real enough that standards bodies have already begun standardizing "post-quantum" cryptographic algorithms designed to resist this kind of attack, intended to eventually replace RSA and similar algorithms in systems that need security guarantees for the decades ahead. For most present-day uses, this isn't an immediate practical concern, but it's worth knowing RSA's security model has a known theoretical weak point that doesn't apply to classical computers.

Limitations of this tool

This tool generates a standalone RSA public/private key pair using the browser's Web Crypto API — it doesn't create a certificate signing request (CSR) or an X.509 certificate, both of which are typically needed to actually use a key pair for something like TLS or code signing, and doesn't offer any secure long-term storage mechanism, since the keys exist only in browser memory and are permanently gone the moment you reload or close the page. If you need a full certificate rather than a raw key pair, or need to store a private key securely for repeated future use, this tool covers only the key generation step — you'll need additional tooling (like OpenSSL, or your certificate authority's own process) for the rest of that workflow.