RSA key pair generator
Generate a new random RSA private and public pem certificate key pair.
About RSA key pair generator
Generates a new random RSA private and public key pair and shows both as PEM text. Generation happens in your browser with a background worker, so the page stays responsive and the keys are never sent anywhere.
When you would use it
- Creating a throwaway key pair for testing signing, encryption, SSH or JWT code.
- Producing keys for a local development environment or a tutorial.
- Trying different key sizes to see how long generation takes.
How to use it
- Set the number of bits (2048 by default, from 256 to 16384 in steps of 8).
- Wait for the key pair to be generated; larger sizes take noticeably longer.
- Copy the public key and the private key, or press the button to generate a new pair.
Things worth knowing
- Use 2048 bits at least; 3072 or 4096 for long-lived keys. Keys below 2048 bits are considered insecure and exist here only for experiments.
- A 4096-bit or larger key can take several seconds to many seconds to generate, and the time varies because prime numbers are searched at random.
- The private key is written in the traditional format (-----BEGIN RSA PRIVATE KEY-----, PKCS#1) and the public key in -----BEGIN PUBLIC KEY-----. Some libraries want PKCS#8 (-----BEGIN PRIVATE KEY-----); convert with: openssl pkcs8 -topk8 -nocrypt -in key.pem.
- Do not use keys generated in a web page for production systems or anything valuable. Generate those on a trusted machine with openssl or your platform's key management service.
Frequently asked questions
- Is the generated key really random?
- Yes. Generation uses the node-forge library with your browser's secure random source, and each click creates an independent key. But as with any web tool, you cannot audit the page you are using, which is why production keys should be made elsewhere.
- Why does the page take a while to produce a key?
- Finding two large random prime numbers is the slow part, and it grows quickly with key size. A 2048-bit key usually appears within a few seconds.