ModernCalcs

RSA Key Pair Generator

Generate a real RSA key pair using native Web Crypto and export it in standard PEM format (PKCS8 private / SPKI public).

RSA Key Pair Generator: Real Keys, Standard PEM Format, No Install

Generating an RSA key pair usually means reaching for OpenSSL on the command line. This tool does the same underlying cryptographic operation — using the browser's native Web Crypto API, not a simulation — and exports the result in the same PEM format OpenSSL produces, so it's a drop-in alternative for quick development and testing work.

Formula
RSA key pair -> SPKI (public, DER) + PKCS8 (private, DER) -> base64 -> PEM

2048-bit is the current widely-accepted minimum; 4096-bit trades speed for extra margin.

Signing vs. Encryption: Same Math, Different Padding

RSA's underlying number theory is the same whether you're signing or encrypting, but the padding scheme differs, and Web Crypto treats them as genuinely different algorithms: RSASSA-PKCS1-v1_5 for signing/verifying (what RS256 JWTs use), and RSA-OAEP for encrypting/decrypting. A key generated for one purpose is exported with usage restrictions matching that choice.

Why PEM Remains the Universal Format

PEM is just base64-encoded DER (a binary ASN.1 encoding) with human-readable BEGIN/END markers — but that simplicity is exactly why it's supported everywhere: OpenSSL, every major language's crypto library, TLS certificate tooling, and most infrastructure-as-code secret managers all accept PEM directly, making it the safest choice when you don't know exactly what will consume the key.

Choosing a Key Size

2048-bit RSA is currently considered secure and is the default minimum recommended by NIST and most security guidance for the foreseeable future. Some organizations mandate 3072 or 4096-bit for long-lived keys (like root CAs) or extra-cautious compliance requirements — the tradeoff is slower key generation and slightly slower cryptographic operations at larger sizes.

Practical Examples

Generating a Dev JWT Signing Key

For RS256-based authentication testing.

  • 1.Key Size: 2048-bit
  • 2.Purpose: Signing
  • 3.Private key signs tokens, public key verifies them

Generating an Encryption Key Pair

For encrypting sensitive test data.

  • 1.Key Size: 2048-bit
  • 2.Purpose: Encryption
  • 3.Public key encrypts, private key decrypts

What This Tool Generates

  • Real RSA key pairs: via native Web Crypto
  • 2048 / 3072 / 4096-bit options
  • Signing or Encryption algorithm variants
  • Standard PEM output: PKCS8 private, SPKI public

Good Use Cases

  • Generating development/test RSA keys without installing OpenSSL
  • Quickly getting a key pair for RS256 JWT experimentation
  • Learning the difference between SPKI and PKCS8 formats
  • Testing RSA-OAEP encryption/decryption flows

Frequently Asked Questions

Is this a real RSA key pair, or a simulated one?

Real — key generation uses crypto.subtle.generateKey(), the browser's native Web Crypto implementation, the same one used by production web applications. Nothing about the key material is faked or simplified.

What key size should I choose?

2048-bit is the current widely-accepted minimum for RSA, considered secure for the foreseeable future for most purposes. 3072 or 4096-bit adds a substantial security margin at the cost of slower operations — reasonable for long-lived keys or higher-assurance requirements.

Should I choose Signing or Encryption?

Choose Signing (RSASSA-PKCS1-v1_5) if you need to sign/verify data, such as generating an RS256 JWT key. Choose Encryption (RSA-OAEP) if you need to encrypt/decrypt data directly with RSA. A single RSA key pair is generated for one purpose at a time — the algorithm choice affects how the key can be used.

Why PEM format specifically?

PEM (base64-encoded DER, wrapped with -----BEGIN/END----- markers) is the most universally recognized key format — accepted directly by OpenSSL, most programming language crypto libraries, TLS tooling, and SSH-adjacent utilities, making it the safest default for portability.

What's the difference between the SPKI and PKCS8 formats used here?

SPKI (SubjectPublicKeyInfo) is the standard container format for public keys. PKCS8 is the standard container format for private keys. Both are DER-encoded ASN.1 structures, PEM-wrapped here for readability and easy copy-pasting.

Is my private key sent anywhere?

No, key generation and export both happen entirely in your browser via the Web Crypto API — private key material never leaves your device. Still, avoid generating keys you intend for production use in a shared or untrusted browser environment.