Public-key cryptography uses two linked keys. Anything locked with the public key can only be opened with the private key, and anything signed with the private key can be checked by anyone with the public key. Developers need key pairs all the time: to sign JWTs, to encrypt data for a partner, to test TLS or SAML integrations, or to set up an API that verifies signed requests.
Choosing the right options
- Encryption (RSA-OAEP): someone encrypts data with your public key; only your private key can read it.
- Signatures (RSA-PSS): the modern RSA signature scheme, for new designs.
- Signatures (PKCS#1 v1.5): the older scheme used by JWT’s RS256 and many existing systems.
- ECDSA: small, fast signature keys. P-256 is what JWT’s ES256 uses.
The underlying key is the same RSA maths in each case, but Web Crypto ties a key to one purpose, and many libraries check that too. That’s why the tool asks up front.
What you get
The public key comes as standard PEM, which almost every library reads, plus JWK for publishing on a /.well-known/jwks.json endpoint. The fingerprint is a short SHA-256 summary you can compare by eye to check you have the right key.
Look after the private key
Download it once and put it where it belongs: a secrets manager, an environment variable on the server, or an encrypted vault. Never commit it to a Git repository or paste it into a chat. If it leaks, generate a new pair and replace the public key everywhere it is used.
How to use the RSA Key Pair Generator
- Choose RSA or Elliptic curve.
- For RSA, pick the key size and what the key is for: encryption, RSA-PSS signatures or PKCS#1 v1.5 (used by JWT RS256).
- Click Generate key pair.
- Copy or download the public and private keys as .pem files. The JWK version is under the keys.
Features
- RSA 2048, 3072 and 4096-bit keys, or ECDSA on P-256, P-384 and P-521.
- Public key in SPKI PEM (
BEGIN PUBLIC KEY), private key in PKCS#8 PEM (BEGIN PRIVATE KEY). - Public key as JWK, ready for a JWKS endpoint.
- SHA-256 fingerprint of the public key, formatted like OpenSSL.
- Generated by your browser’s Web Crypto API; the private key is never sent anywhere.
Frequently asked questions
Which key size should I choose?
2048-bit RSA is the minimum accepted today and is fine until about 2030. 3072-bit matches 128-bit security and is a good default for new keys. 4096-bit is slower to use and gives a smaller extra margin. For signatures, an ECDSA P-256 key is as strong as 3072-bit RSA and much smaller.
Can I use these keys for SSH?
Not directly. SSH uses its own key format. Convert the private key with ssh-keygen -y -f private.pem to get the public key line, or simply run ssh-keygen, which creates SSH keys in the right format.
Is it safe to generate a private key in a browser?
The key is made by the browser’s built-in crypto, the same code that secures HTTPS, and stays in this tab. For keys that protect production systems, many organisations still prefer to generate them on the server or in a hardware security module, so the key never exists anywhere else.
Why is the private key not password-protected?
Web Crypto exports keys unencrypted. Add a passphrase with openssl pkcs8 -topk8 -in private.pem -out private-enc.pem, or store the file in a secrets manager.
Written by Dewan Razib