Skip to content

RSA key generator

Free, no sign-up Runs in your browser

Generate an RSA key pair of 2048, 3072 or 4096 bits with Web Crypto and export it as PKCS#8 and SPKI PEM. The private key never leaves your browser.

Key size

2048 is the minimum in use today. 3072 matches 128-bit security. 4096 is slower to generate and to use; it can take several seconds here.

Private key (PKCS#8 PEM)
-----BEGIN PRIVATE KEY----- appears here.
Public key (SPKI PEM)
-----BEGIN PUBLIC KEY----- appears here.

The key pair is made by your browser’s Web Crypto and never leaves this page. Even so, generate production keys on the machine that will use them (openssl genpkey, ssh-keygen, your cloud’s key service), so the private key is never in a browser tab or a clipboard. Use keys from this page for development, tests and learning.

The private key is not encrypted with a passphrase. Public exponent 65537. To get the older “BEGIN RSA PRIVATE KEY” form: openssl rsa -in key.pem -traditional -out rsa.pem

Everything you type here stays in your browser. Nothing is sent to HardenKit or to anyone else.

How to use the RSA key generator

  1. Choose a key size. 2048 bits is quick; 4096 can take several seconds.
  2. Press Generate key pair.
  3. Copy the private key and the public key. They are shown as PEM.
  4. Keep the private key out of repositories, and generate production keys on the machine that will use them.

About this tool

An RSA key pair is two linked keys. The private key signs and decrypts and must stay with its owner. The public key verifies and encrypts and can be given to anyone. The pair is built from two large random primes, and its strength is the size of their product: 2048 bits is the minimum accepted today, 3072 matches the 128-bit security level, and 4096 adds margin at the cost of slower signing.

This tool asks your browser’s Web Crypto to generate the pair with the standard public exponent 65537 and shows both halves as PEM. The private key is PKCS#8, the block that begins BEGIN PRIVATE KEY. The public key is SPKI, BEGIN PUBLIC KEY. OpenSSL, Node.js, Java, Go, Python and JWT libraries all read those formats. The key is created and held in this page only; nothing is sent to a server.

Even so, treat keys from any web page as development keys. A production private key should be generated on the machine that will use it, or in a hardware module or cloud key service, so it never passes through a browser tab or a clipboard. Use this page for local testing, examples, CI fixtures and learning the formats. For new systems also consider elliptic curve keys: ECDSA P-256 and Ed25519 are smaller and faster.

Sources

Questions

What RSA key size should I use?

At least 2048 bits, which NIST accepts through 2030. Use 3072 bits for keys that must last beyond that or to match a 128-bit security level. 4096 is common for long-lived keys but makes private-key operations several times slower than 2048.

What is the difference between PKCS#1 and PKCS#8?

PKCS#1 is the RSA-only format, with the header BEGIN RSA PRIVATE KEY. PKCS#8 wraps any kind of private key with an algorithm identifier and has the header BEGIN PRIVATE KEY. They hold the same key, and OpenSSL converts between them. Web Crypto exports PKCS#8.

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

The generation itself uses the browser’s vetted cryptography and this page sends nothing out. The risk is everything around it: browser extensions, clipboard history, and the habit of pasting keys. For keys that protect real systems, generate them where they will live and never move the private half.

Should I use RSA or ECDSA?

For new systems, elliptic curve keys such as ECDSA P-256 or Ed25519 give equivalent security with much smaller keys and faster signing. RSA remains the most widely compatible choice and verifies quickly. Pick RSA when something you must work with requires it.

How do I generate the same kind of key with OpenSSL?

Run openssl genpkey -algorithm RSA -pkeyopt rsa_keygen_bits:2048 -out private.pem for the private key in PKCS#8, then openssl pkey -in private.pem -pubout -out public.pem for the public key. Doing it on the target machine keeps the private key in one place.

Related tools