Home › All Tools ›

RSA Key Pair Generator

Use RSA Key Pair Generator online for free at FreeToolZones — no sign-up, no watermark.

Loading tool...

Public-key cryptography lets two parties exchange secret information without ever sharing a secret in advance. The RSA Key Pair Generator creates the foundation of that system: a matched pair of keys, one public and one private, generated entirely in your browser. The public key can be shared freely with anyone who needs to encrypt a message for you. The private key must be kept secret, because anyone who holds it can decrypt messages encrypted with the public key. This tool produces both keys in standard PEM format, ready to copy or download, with a choice of 2048-bit or 4096-bit key size. The keys never leave your browser, so the private key is never transmitted to a server or stored anywhere except where you choose to save it.

What Is the RSA Key Pair Generator?

The RSA Key Pair Generator is a free browser-based tool that generates RSA-OAEP key pairs using the Web Cryptography API. RSA is one of the oldest and most widely used public-key algorithms. It is based on the difficulty of factoring the product of two large prime numbers, which makes it practical to publish a public key while keeping the corresponding private key secret. OAEP, Optimal Asymmetric Encryption Padding, is the padding scheme used with RSA for encryption, and this tool pairs it with SHA-256 as the hash function. The keys are generated for encryption and decryption: the public key encrypts, and the private key decrypts.

You choose a key size of 2048 bits or 4096 bits. The 2048-bit option is labeled recommended, because it offers a widely accepted security level with faster generation. The 4096-bit option is described as slower but stronger, and generation can take a few seconds while the browser searches for suitable prime numbers. The tool disables the generate button and shows a Generating message during that wait, so you know it is working. Once generation finishes, the public key is exported in SPKI format and the private key in PKCS8 format, both wrapped as PEM text with the familiar BEGIN and END header lines and Base64 content split into 64-character lines.

The distinction between the two keys is the whole point of the tool. The public key is meant to be shared: you can send it to colleagues, publish it, or embed it in an application. The private key is meant to be guarded: the tool labels it keep this secret, and the hint below the tool warns that anyone with the private key can decrypt messages encrypted with the public key. The tool itself never sees a server, so the only copies of the private key are the ones you create by copying or downloading it.

How to Use the RSA Key Pair Generator

  1. Choose the key size. Select 2048 bits (recommended) for general use, or 4096 bits if you want a larger security margin and can accept slower generation. Most applications and standards accept 2048-bit RSA keys.
  2. Click Generate Key Pair. Press the Generate Key Pair button. The button changes to a Generating message and is disabled while the browser creates the keys. For 4096-bit keys, this can take a few seconds. Do not close the page during generation.
  3. Review the two keys. The public key appears in a field labeled Public key (share this), and the private key appears in a field labeled Private key (keep this secret). Both fields are read-only, so you cannot accidentally edit the key text.
  4. Copy or download the public key. Use Copy Public Key to copy the PEM text, or Download Public Key to save it as public_key.pem. Share this key with anyone who needs to encrypt messages for you.
  5. Copy or download the private key securely. Use Copy Private Key or Download Private Key to save the private key as private_key.pem. Store it in a secure location, such as an encrypted volume or a secrets manager, with restricted file permissions. Never email it, paste it into chat, or commit it to a shared code repository.
  6. Generate a fresh pair when needed. If a private key may have been exposed, generate a new pair, distribute the new public key, and stop using the old private key. There is no way to repair a compromised private key.

Key Features of the RSA Key Pair Generator

  • RSA-OAEP with SHA-256. Keys are generated for the RSA-OAEP algorithm with SHA-256, a modern and widely supported combination for encryption, using the browser WebCrypto implementation.
  • Two key sizes. Choose 2048 bits for a recommended balance of security and speed, or 4096 bits for a stronger key that takes longer to generate.
  • Standard PEM export. The public key is exported as SPKI and the private key as PKCS8, both in PEM format with Base64 lines, compatible with many tools and libraries that accept PEM keys.
  • Separate copy and download buttons. Each key has its own copy and download controls, reducing the risk of accidentally copying the private key when you meant the public key.
  • Read-only result fields. The key text cannot be edited in place, which prevents accidental corruption of the PEM format before copying.
  • Generation progress feedback. The button shows that generation is in progress and is disabled until it finishes, preventing duplicate generations and confusion during the wait.
  • Local generation only. Keys are created in your browser and never leave it. The private key is never uploaded, logged, or stored by the site.

Practical Use Cases With Concrete Examples

Learning how public-key encryption works. A student can generate a pair, share the public key with a classmate, and have the classmate encrypt a message that only the student can decrypt. The experiment makes the abstract idea of asymmetric keys concrete, without installing any software.

Prototyping an encrypted messaging feature. A developer building a prototype can generate a test key pair in seconds and use the PEM files to test encryption and decryption code, without setting up a key management service. Test keys should never be used in production, where keys need proper storage and rotation.

Encrypting data for one recipient. If you need to send sensitive data to a single person, they can generate a key pair, send you the public key, and you encrypt the data with it. Only their private key can decrypt it, so the encrypted data can travel through ordinary channels.

Creating keys for a small project. A hobby project that needs to encrypt configuration values or tokens can use a generated pair during development, with the private key stored securely by the project owner and the public key embedded in the tool that performs encryption.

Demonstrating key handling practices. A trainer can use the tool to show the difference between public and private keys, the PEM format, and the importance of keeping the private key secret, using disposable keys that can be discarded after the demonstration.

Testing interoperability. Because the output is standard PEM, developers can test whether their libraries and tools can import SPKI public keys and PKCS8 private keys, catching format problems early before integrating with a production key source.

Tips and Best Practices

  • Guard the private key from the moment it is created. The private key is sensitive as soon as it exists. Save it to a secure location immediately, restrict who can read the file, and do not leave it in clipboard history or downloads folders that are shared or synced insecurely.
  • Use 2048 bits unless you have a reason for more. The recommended size is suitable for most purposes. Choose 4096 bits when a policy requires it or when the key will protect data for a very long time, and accept the slower generation.
  • Never share the private key. There is no legitimate reason to send a private key to another person. If someone asks for it, that is a serious warning sign. Share only the public key.
  • Replace a key pair if exposure is suspected. If a private key file was emailed, uploaded, or stored in a shared location, treat it as compromised. Generate a new pair and distribute the new public key.
  • Back up the private key securely. If the only copy of a private key is lost, data encrypted with the public key cannot be decrypted. Keep an encrypted backup in a second secure location, and protect the backup with the same care as the original.
  • Understand what RSA-OAEP keys are for. These keys are generated for encryption and decryption. They are not signing keys. For SSH authentication, use the SSH Key Generator, which produces keys in the format SSH expects.
  • Do not use browser-generated keys for high-value production systems without a key management plan. Production keys need secure storage, access control, rotation, and audit, which a browser tool cannot provide. Use this tool for learning, testing, and small-scale needs, and use a managed key service for production.

Limitations

The RSA Key Pair Generator is a general-purpose key creation tool with specific limits. It generates RSA-OAEP keys for encryption and decryption only; it does not generate signing keys, and it does not perform encryption or decryption itself. The private key is exported unencrypted in PKCS8 PEM format, which means anyone who obtains the file can use it immediately, without a passphrase. You must protect the file with filesystem permissions, encryption, or a secrets manager. Key generation requires WebCrypto over HTTPS in a modern browser, and 4096-bit generation can take several seconds depending on the device. The tool does not provide a certificate, does not register the key anywhere, and does not verify the identity of the key holder, so a public key received from someone must be verified through a trusted channel before you rely on it. RSA key sizes and algorithm choices evolve over time, and what is recommended today may change; check current guidance from a standards body before choosing a key size for long-lived data. Finally, the security of the keys depends on the security of the browser and device: a compromised device could capture the private key as it is generated.

Frequently Asked Questions

What is the difference between the public key and the private key?

The public key encrypts data and can be shared freely. The private key decrypts data encrypted with the public key and must be kept secret. The two keys are mathematically linked, but the private key cannot feasibly be derived from the public key.

Should I choose 2048 or 4096 bits?

Choose 2048 bits for most purposes; it is the recommended size and generates faster. Choose 4096 bits if you want a larger security margin or a policy requires it, and you can accept slower generation and slightly slower operations.

Is the private key sent to a server?

No. Generation and export happen entirely in your browser. The private key never leaves your device unless you copy or download it, and the site never stores it.

Can I use these keys for SSH?

Not directly in the form produced here. SSH expects keys in OpenSSH format and uses signing algorithms. Use the SSH Key Generator on this site, which produces an OpenSSH public key and a PEM private key suitable for SSH.

What happens if I lose the private key?

Data encrypted with the public key cannot be decrypted without the private key. There is no recovery. Keep a secure encrypted backup of any private key that protects data you need to keep.

Can I use the keys in my own software?

Yes, if your software or library can import PEM-encoded SPKI public keys and PKCS8 private keys for RSA-OAEP with SHA-256. Check your library documentation for import support, and test with a disposable key pair first.

Keys, Identity, and Trust

A public key is only useful if you know whose key it is. The mathematics of RSA guarantees that data encrypted with a public key can be decrypted only by the matching private key, but mathematics alone cannot tell you whether the public key you received really belongs to the person you think it does. An attacker who substitutes their own public key can intercept messages intended for someone else, decrypt them with their own private key, and re-encrypt them for the real recipient, reading everything in transit. Preventing that substitution requires verifying the key through a trusted channel: comparing a fingerprint of the key by phone, receiving it in person, downloading it from a verified website over HTTPS, or relying on a certificate issued by a trusted authority that binds the key to an identity. For casual learning and testing, that verification may be informal, but for any real exchange of sensitive data, it is essential. Never encrypt sensitive data with a public key received in an unverified email or message without confirming its authenticity through a second channel. The key pair generator creates the keys; trust in the keys must be established by the people using them, through processes outside the tool.

Related Tools

Explore related tools: the SSH Key Generator creates SSH key pairs, the AES Encryption Tool encrypts text with a password, the Secret Key Generator creates random symmetric keys, the Hash Checker computes hashes for integrity checks, and the API Key Generator creates keys for services. Return to the homepage to browse all free tools.

Browse More Tools