● Security & Privacy Tools

RSA Key Generator - Generate 2048, 3072 & 4096-bit Keypairs

Generate public and private RSA keypairs (2048, 3072, and 4096-bit) in PEM (PKCS#1 / PKCS#8) and OpenSSH formats online.

Free to Use
No sign-up required
100% Client-Side
Your data stays private
Instant Results
Get results in seconds

RSA Key Generator

Generate public and private RSA keypairs (2048, 3072, and 4096-bit) in PEM (PKCS#1 / PKCS#8) and...

100% Zero-Knowledge Client-Side Key Generation: Cryptographic RSA keys are computed locally in your web browser memory using the Web Crypto API. Neither private nor public keys are ever transmitted over the network.
Key Size (Bits)
Key Purpose
SSH Comment / ID
Paste Existing RSA Key (Public or Private in PEM / OpenSSH)

Useful SSH & OpenSSL Commands

1. Setup Private Key Permissions on Linux / macOS:
chmod 600 ~/.ssh/id_rsa
chmod 644 ~/.ssh/id_rsa.pub
2. Add Key to SSH Agent:
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_rsa
3. Extract Public Key from Private Key (OpenSSL):
openssl rsa -in id_rsa -pubout -out public.pem
4. Test SSH Connection to GitHub:
ssh -T git@github.com
Tool Details

About RSA Key Generator

● Security & Privacy Tools

What is an RSA Key Generator & How Does It Work?

The ToolSpark RSA Key Generator is an online cryptographic tool designed for developers, systems administrators, and DevOps professionals who require standard PKCS#1 and PKCS#8 asymmetric RSA key pairs. Executing directly inside your web browser via the standard W3C Web Cryptography API (`crypto.subtle.generateKey`), this utility generates mathematically rigorous prime factors to synthesize private and public keys in standard PEM (Privacy-Enhanced Mail) formatting without transmitting sensitive private data over the internet.

The Mathematics Behind RSA Cryptography

Named after its inventors Ron Rivest, Adi Shamir, and Leonard Adleman, the RSA algorithm derives its cryptographic strength from the computational hardness of the integer factorization problem:

  1. Two massive, distinct random prime numbers $p$ and $q$ are chosen via cryptographically secure pseudo-random number generators (CSPRNG).
  2. The modulus $n = p imes q$ is calculated. The length of $n$ in bits determines the key length (e.g., 2048, 3072, or 4096 bits).
  3. Euler's totient function $\phi(n) = (p-1)(q-1)$ is computed.
  4. A public exponent $e$ (commonly 65537, or $2^{16} + 1$) is selected such that $\gcd(e, \phi(n)) = 1$.
  5. The private exponent $d$ is computed as the modular multiplicative inverse: $d \equiv e^{-1} \pmod{\phi(n)}$.

The public key is $(n, e)$, and the private key is $(n, d)$. While multiplying $p$ and $q$ takes microseconds, factorizing $n$ back into $p$ and $q$ without knowledge of $d$ would take millions of years with modern supercomputers.

---

Realistic Worked Examples

Example 1: Creating an API Signing Key Pair (RSA 2048-bit)

  • Parameters: 2048-bit key depth, PKCS#8 PEM format.
  • Output:
  • Private Key: `-----BEGIN PRIVATE KEY-----` (Base64 ASN.1 sequence containing $n, e, d, p, q, d_p, d_q, q_{inv}$)
  • Public Key: `-----BEGIN PUBLIC KEY-----` (Base64 SubjectPublicKeyInfo containing $n$ and $e$)
  • Use Case: Used by an authentication server to issue and sign asymmetric JWT tokens (`RS256`).

Example 2: Enterprise Root Certificate Key (RSA 4096-bit)

  • Parameters: 4096-bit key depth.
  • Use Case: Used as the private key foundation for generating self-signed TLS certificates and OpenSSL certificate signing requests (CSRs).

---

Step-by-Step Guide: How to Generate RSA Keys

  1. Select Key Size: Choose between 2048-bit (standard commercial speed), 3072-bit (NIST recommended through 2030), or 4096-bit (maximum enterprise resilience).
  2. Choose Output Format: Select standard PKCS#8 (universal modern standard) or legacy PKCS#1 format.
  3. Click "Generate Key Pair": Your browser generates high-entropy prime numbers and builds the ASN.1 structures.
  4. Copy or Download Keys: Download the public key (`public.pem`) and private key (`private.pem`) for use in OpenSSL, Node.js, Python, or Go applications.

---

Who Uses This Tool & Practical Scenarios

  • Backend Developers: Implementing asymmetric encryption for payment tokenization, payload verification, and webhook authenticity.
  • DevOps Engineers: Generating key pairs for service-to-service mutual TLS (mTLS), Kubernetes secrets, and OpenSSL configurations.
  • Cloud Architects: Configuring AWS CloudFront signed URLs and private API gateway authentication policies.
  • Security Students: Studying the mathematical structure and ASN.1 formatting of modern public-key cryptography.

---

Security Best Practices

  • 2048-bit Minimum: Never use RSA keys smaller than 2048 bits for production environments. NIST recommends 3072 or 4096-bit keys for long-term security.
  • Client-Side Generation Only: Never generate production root production keys on public shared computers. ToolSpark processes everything client-side for rapid development and testing.

Complement your setup with our SSH Key Generator, create authentication tokens with JWT Generator & Decoder, or inspect certificates with SSL Certificate Checker.

---

Asymmetric Key Cryptography, Prime Number Generation & Modulus Sizes

The RSA cryptosystem (Rivest–Shamir–Adleman) forms the bedrock of secure internet communications, TLS handshakes, and enterprise encryption:

  • Choosing Modulus Bit Length (2048 vs. 4096 bits):
  • 2048-bit RSA: Currently provides acceptable security (equivalent to approximately 112 bits of symmetric security) according to NIST guidelines, suitable for general application testing and short-term keys.
  • 4096-bit RSA: Recommended for long-term root Certificate Authorities (CAs), master PGP identities, and enterprise archival encryption, offering robust resistance against escalating factoring capabilities.
  • The Importance of Large Prime Generation: RSA security rests upon the computational difficulty of factoring the product ($n = p imes q$) of two massive, randomly generated prime numbers. Generating cryptographically secure primes requires continuous entropy gathering from system hardware events (`crypto.getRandomValues`) to prevent prime predictability.
  • Public Exponent Standard ($e = 65537$): The fourth Fermat number ($F_4 = 2^{16} + 1 = 65537$) is universally utilized as the standard public exponent. Its binary structure contains only two set bits (`10000000000000001`), providing lightning-fast modular exponentiation while defending against low-exponent factoring attacks.

Regulatory & Enterprise Standards

  • PKCS #1 (RFC 8017): RSA Cryptography Specifications Version 2.2.
  • Format Exports: PEM-encoded PKCS#1 (`BEGIN RSA PRIVATE KEY`) and PKCS#8 (`BEGIN PRIVATE KEY`) formats for universal server compatibility.
  • Related Key Tools: Compare with our modern SSH Key Generator, PGP Key Generator, and AES Encrypt / Decrypt.
Quick Tip
For modern microservices and web APIs, select PKCS#8 format for seamless compatibility with Node.js, Python cryptography, and OpenSSL.

Why Generate RSA Keys with ToolSpark?

Native Web Crypto API Engine

2048, 3072 & 4096-Bit Depths

PKCS#8 & PKCS#1 PEM Output

100% In-Browser Privacy

One-Click Copy & Download

FAQ

Frequently Asked Questions About RSA Key Generator

What is the difference between PKCS#1 and PKCS#8?

PKCS#1 is the legacy RSA-specific format (identified by 'BEGIN RSA PRIVATE KEY'), whereas PKCS#8 is a modern, algorithm-agnostic standard (identified by 'BEGIN PRIVATE KEY') supported by all modern cryptographic libraries.

Is 2048-bit RSA still secure?

Yes, 2048-bit RSA remains secure against current practical attacks and is approved by NIST. However, for sensitive data requiring security beyond 2030, 3072 or 4096-bit keys are recommended.

Can I use these keys with OpenSSL?

Yes. The generated PEM blocks are 100% standard and can be directly used in OpenSSL commands such as 'openssl rsa -in private.pem -text'.

Why is the public exponent e usually 65537?

65537 (0x10001 in hex) is a Fermat prime (F4). In binary, it has only two set bits (10000000000000001), allowing ultra-fast modular exponentiation while preventing low-exponent cryptanalytic attacks.

Are my private keys saved anywhere?

No. The keys exist only in your browser's temporary memory and are permanently wiped as soon as you refresh or close the page.

Can I use this RSA key pair to sign JWT tokens?

Yes, these keys are perfectly formatted for asymmetric RS256, RS384, and RS512 JSON Web Token signing and verification.

How do I extract the public key from the private key later?

You can derive the public key using OpenSSL with the command: 'openssl rsa -in private.pem -pubout -out public.pem'.

Is this generator completely free?

Yes, ToolSpark RSA Key Generator is completely free with no usage limitations or registration requirements.