DevKit
Crypto

RSA Key Generator

Generate an RSA public/private keypair in PEM format, in your browser.

Last updated: August 2026

RSA keys are generated locally via Web Crypto and never leave your browser. For real production keys, generate them in a trusted environment.

Share:

Was this tool helpful?

Generating an asymmetric keypair

RSA produces a matched pair: a public key you can hand out freely and a private key you must guard. Data encrypted to the public key can only be decrypted with the private key, and signatures made with the private key can be checked by anyone holding the public one. The pair is derived from two large random prime numbers whose product forms the modulus.

Why key size matters

Security rests on the difficulty of factoring that modulus back into its primes. A 1024-bit key is now considered weak; 2048 bits is the practical minimum, and 3072 or 4096 bits buys more margin at the cost of slower operations and larger keys. Larger keys mainly slow signing and decryption, which happen on the private-key side.

Example

-----BEGIN PUBLIC KEY-----
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8A...
-----END PUBLIC KEY-----

-----BEGIN PRIVATE KEY-----
MIIEvQIBADANBgkqhkiG9w0BAQEFAASC...
-----END PRIVATE KEY-----

PEM is just Base64-encoded DER wrapped in those header lines. The public key carries the modulus and exponent; the private key additionally holds the primes and other values needed to decrypt. You can inspect the raw structure with the ASN.1 parser.

Handling the private key

The private key is the whole ballgame. If it leaks, every signature and every message encrypted to the matching public key is compromised, and you cannot un-leak it. Generate it where it will live, protect it with a passphrase if the format supports one, and never paste a production private key into a page you do not control.

FAQ

Should I use RSA or an elliptic-curve key? EC keys (like Ed25519 or P-256) give equivalent security with much smaller keys and faster operations. RSA is still everywhere for compatibility, which is often the deciding factor.

Can I regenerate the public key from the private one? Yes. The private key contains everything needed to derive the public key. The reverse is not possible.