Skip to main content

Create RSA Key Pairs in Your Browser Generate RSA key pairs using the Web Crypto API.

RSA Key Generator illustration
🔐

RSA Key Generator

Generate RSA key pairs using the Web Crypto API.

1

Select Key Size

Choose 1024, 2048, or 4096 bits using the size buttons.

2

Generate Keys

Click Generate to create a new RSA key pair.

3

Copy Keys

Use Copy buttons next to each key output.

Loading tool...

What Is RSA Key Generator?

A RSA Key Generator is a software tool that creates a pair of public and private keys using the RSA algorithm, enabling secure data encryption and decryption. Developers working with online applications, such as TLS or SSH, use it to generate unique key pairs for secure communication. One specific problem it solves is providing a simple way to create RSA key pairs in a web-based environment, eliminating the need for command-line tools like OpenSSL.

It allows users to select from three different key sizes: 1024 bits, 2048 bits, and 4096 bits, giving them control over the level of security they need. The tool uses the Web Crypto API's SubtleCrypto interface to generate keys, ensuring that private keys never leave the user's browser, keeping sensitive information secure. This is particularly useful when generating RSA public private keys online.

What makes this tool different is its ability to export generated keys in PEM format, compatible with popular encryption tools like OpenSSL and SSH clients. The RSA Key Generator also includes features like automatic copying of generated keys to the clipboard, making it easy to integrate them into existing applications. When you generate RSA keys using this tool, you can be sure that your private key will remain secure, as it is never transmitted outside of your browser, allowing for safe generation of RSA key pairs online.

Why Use RSA Key Generator?

  • Fast, accurate processing
  • 100% client-side — data never leaves your browser
  • Free online tool with no signup required
  • Mobile-friendly with 44px touch targets

Common Use Cases

Development

Use in software development workflows.

Security

Cryptographic and security applications.

Education

Learn about algorithms and techniques.

Verification

Verify and validate data integrity.

Technical Guide

The tool works by utilizing the Web Crypto API's SubtleCrypto interface to generate a pair of public and private keys using the RSA-OAEP algorithm with a modulus length defined by the user's selected key size. This process involves generating large prime numbers p and q, then calculating n as their product and selecting e as 65537, a commonly used value for its relatively small size and ease of calculation. The corresponding private exponent d is calculated such that e*d = 1 mod phi(n), where phi(n) represents Euler's totient function applied to n.

When the user initiates key generation, it triggers an asynchronous call to window.crypto.subtle.generateKey with parameters specifying RSA-OAEP as the algorithm and defining the public exponent. The generated keys are then exported in SPKI (Subject Public Key Information) format for the public key and PKCS#8 format for the private key using the SubtleCrypto interface's exportKey method, resulting in ArrayBuffer objects that contain the encoded key data.

These ArrayBuffers are subsequently converted to base64 strings through a process involving creation of Uint8Array views from the buffers, followed by transformation into binary strings and finally application of btoa function for base64 encoding. The formatted PEM (Privacy Enhanced Mail) strings are then constructed by wrapping these base64-encoded strings with headers indicating whether they represent public or private keys.

Key sizes such as 1024 bits, 2048 bits, and 4096 bits determine the modulus length in the RSA-OAEP algorithm used for key generation. A minimum recommended key size of 2048 bits is typically suggested to ensure sufficient security against factorization attacks on n. The generated public and private keys are then presented to the user within textareas, where they can be easily copied using provided copy buttons that invoke a function utilizing the copyToClipboard utility from the utils library.

The tool's use of React state management with useState allows it to maintain an up-to-date representation of key generation status and any generated keys. Once keys are successfully generated or if an error occurs during this process, updates to relevant states trigger re-renders that display the resulting public and private keys in PEM format to the user.

Implementation details like handling different button click events for key size selection and copy functionality rely on React's event handling mechanisms, alongside its useCallback hook to memoize functions such as generateKeys and handleCopy. By using these technologies and APIs, it efficiently generates RSA key pairs within a web-based environment while ensuring private keys remain secure by never leaving the user's browser.

Tips & Best Practices

  • 1
    All processing happens in your browser
  • 2
    Each generation produces a new unique key pair
  • 3
    Use Copy button to quickly grab output
  • 4
    Works on mobile devices with touch-friendly interface

Related Tools

Frequently Asked Questions

Q Is this tool free?
Yes, completely free with no signup required.
Q Is my data secure?
Yes. All processing is 100% client-side.
Q Does it work on mobile?
Yes, with responsive design and touch-friendly controls.
Q What browsers are supported?
All modern browsers including Chrome, Firefox, Safari, and Edge.
Q Can I use this offline?
The tool requires an initial page load but processes data locally.

About This Tool

RSA Key Generator is a free online tool by FreeToolkit.ai. All processing happens directly in your browser — your data never leaves your device. No registration or installation required.