Generate RSA Key Pairs

Generate secure RSA public and private key pairs in PEM format.

The RSA Key Pair Generator creates cryptographically secure RSA public and private keys directly in your browser using the Web Crypto API. Choose key sizes of 2048, 3072, or 4096 bits and hash algorithms SHA-256, SHA-384, or SHA-512 to meet your security requirements.

Your data stays in your browser
Tutorial

How to Use

1
1

Select Key Size and Hash

Choose a key size (2048, 3072, or 4096 bits) and a hash algorithm (SHA-256, SHA-384, or SHA-512).

2
2

Generate the Key Pair

Click the Generate button to create your RSA public and private keys using the Web Crypto API.

3
3

Copy Your Keys

Use the copy buttons to copy your PEM-formatted public or private key to the clipboard for use in your project.

Guide

Complete Guide to RSA Key Generation

What Is RSA Encryption?

RSA (Rivest-Shamir-Adleman) is one of the first public-key cryptosystems and remains widely used for secure data transmission. It relies on the mathematical difficulty of factoring the product of two large prime numbers. RSA supports both encryption (confidentiality) and digital signatures (authentication and integrity). The algorithm was published in 1977 and has since become a cornerstone of internet security, used in TLS, SSH, PGP, and countless other protocols.

How RSA Key Generation Works

RSA key generation involves selecting two large random prime numbers, computing their product (the modulus), and deriving the public and private exponents. The public exponent is typically 65537 (0x10001). The private exponent is computed using the extended Euclidean algorithm such that it is the modular inverse of the public exponent modulo the totient of the modulus. The security of RSA rests on the assumption that factoring the modulus back into its prime components is computationally infeasible for sufficiently large key sizes.

Key Sizes and Security Levels

The security of an RSA key is directly related to its bit length. A 2048-bit key provides approximately 112 bits of security, 3072-bit provides about 128 bits, and 4096-bit provides roughly 152 bits. NIST and other standards bodies recommend a minimum of 2048 bits for RSA keys used through 2030. Larger keys offer more security but require more computation time for generation, encryption, and decryption operations. For most web and enterprise applications, 2048 or 3072 bits strikes the right balance.

Best Practices for RSA Key Management

Never share or expose your private key; store it securely with appropriate file permissions or in a hardware security module (HSM). Use separate key pairs for different purposes such as signing versus encryption. Rotate keys periodically according to your organization's security policy. Always use a strong random number generator (such as the Web Crypto API) for key generation. Consider using key sizes of 3072 bits or larger for long-lived keys that need to remain secure for many years.

Examples

Worked Examples

Example: Generating a 2048-bit RSA Key Pair with SHA-256

Goal: Create an RSA key pair suitable for a web application's JWT token signing.

1

Step 1: Select 2048 bits as the key size; this provides 112-bit security which is adequate for JWT signing.

2

Step 2: Select SHA-256 as the hash algorithm; this is the standard hash used in RS256 JWT signatures.

3

Step 3: Click Generate and wait for the browser's Web Crypto API to produce the key pair.

4

Step 4: Copy the private key to your server configuration for signing tokens, and distribute the public key for verification.

Result: A PEM-encoded 2048-bit RSA key pair ready for RS256 JWT signing.

Example: Generating a 4096-bit RSA Key Pair for Long-Term Document Signing

Goal: Create a high-security RSA key pair for signing legal documents that must remain verifiable for 10+ years.

1

Step 1: Select 4096 bits for maximum security margin against future computational advances.

2

Step 2: Select SHA-512 for the strongest available hash algorithm to match the key strength.

3

Step 3: Generate the key pair and securely store the private key in a hardware security module or encrypted vault.

Result: A PEM-encoded 4096-bit RSA key pair with SHA-512, suitable for long-term document signing.

Use Cases

Use Cases

SSH Server Authentication

Generate an RSA key pair to set up SSH key-based authentication for secure server access. Replace password logins with cryptographic keys to eliminate brute-force attack vectors and simplify automated deployment pipelines.

TLS/SSL Certificate Signing

Create RSA keys for generating Certificate Signing Requests (CSRs) used to obtain TLS/SSL certificates. These certificates encrypt web traffic between clients and servers, ensuring data confidentiality and integrity.

Code and Document Signing

Use RSA key pairs to digitally sign software releases, packages, or documents. Recipients can verify the signature with your public key to confirm authenticity and detect any tampering during distribution.

Frequently Asked Questions

?What is an RSA key pair?

An RSA key pair consists of a public key and a private key. The public key can be shared openly and is used to encrypt data or verify signatures. The private key must be kept secret and is used to decrypt data or create signatures. Together they form the basis of asymmetric cryptography.

?What key size should I choose?

For most modern applications, 2048 bits provides adequate security. Use 3072 bits for medium-term protection (through 2030+) and 4096 bits for maximum security where performance is not critical. NIST recommends at least 2048 bits for RSA keys.

?What is PEM format?

PEM (Privacy Enhanced Mail) is a Base64-encoded format for storing cryptographic keys and certificates. PEM files begin with -----BEGIN PUBLIC KEY----- or -----BEGIN PRIVATE KEY----- headers and are the most widely supported key format across tools and platforms.

?What hash algorithm should I use?

SHA-256 is the standard choice for most applications. SHA-384 and SHA-512 offer larger hash outputs and may be required by certain compliance frameworks or when extra security margin is desired.

?Can I use these keys for SSH?

The keys generated are in PKCS#8/SPKI PEM format. While SSH typically uses its own key format, many tools like ssh-keygen can convert PEM keys to OpenSSH format. For direct SSH use, you may need to convert the output.

?Is my data private when using this tool?

Yes. All key generation happens entirely in your browser using the Web Crypto API. No keys, inputs, or data are ever sent to any server. Your private key never leaves your device.

?Is this RSA key generator free?

Yes. This tool is completely free to use with no limits, no sign-up required, and no ads. Generate as many key pairs as you need.

Related Tools

Help us improve

How do you like this tool?

Every tool on Kitmul is built from real user requests. Your rating and suggestions help us fix bugs, add missing features and build the tools you actually need.

Rate this tool

Tap a star to tell us how useful this tool was for you.

Suggest an improvement or report a bug

Missing a feature? Found a bug? Have an idea? Tell us and we'll look into it.

Recommended Reading

Recommended Books on Cryptography & Security

As an Amazon Associate we earn from qualifying purchases.

Boost Your Capabilities

Recommended Security Products

As an Amazon Associate we earn from qualifying purchases.

Newsletter

Get Free Productivity Tips & New Tools First

Join makers and developers who care about privacy. Every issue: new tool drops, productivity hacks, and insider updates — no spam, ever.

Priority access to new tools
Unsubscribe anytime, no questions asked