# RSA Key Pair Generator

Generate an RSA key pair (2048/3072/4096-bit) as PEM-encoded public and private keys. Optionally encrypt the private key with a passphrase. PKCS#8 (recommended) or PKCS#1 private key format. Everything runs locally.

> Canonical page: https://elysiatools.com/en/tools/rsa-key-generator

- **Category:** Security

- **Keywords:** rsa, key pair, public key, private key, pem, pkcs8, pkcs1, asymmetric, cryptography, generate

## Overview

Produces a matching RSA public/private key pair using Node's `crypto.generateKeyPairSync()`.

- **Key size**: 2048 (the modern baseline), 3072, or 4096 bits. Larger = more security but slower. 2048 is fine for most uses; use 4096 for long-term protection.
- **Private key format**:
  - **PKCS#8** (recommended) — generic format, works everywhere, supports passphrase encryption.
  - **PKCS#1** — RSA-specific (older), label `RSA PRIVATE KEY`. Cannot be encrypted with a passphrase in this tool.
- **Passphrase**: if provided, the private key is encrypted (AES-256-CBC) and cannot be used without it.

The public key is always SPKI format (`PUBLIC KEY`).

Use cases: setting up HTTPS, JWT signing keys, SSH from RSA, learning asymmetric crypto. The keys are generated locally and never transmitted.

## Inputs

- **Key size** (select)
- **Private key format** (select)
- **Passphrase (optional, encrypts private key)** (text): Leave empty for an unencrypted key…

## When to use

- When you need to generate secure SSH keys or SSL/TLS certificates for server authentication.
- When setting up token-based authentication systems that require RSA public/private key pairs for JWT signing and verification.
- When you need to quickly generate cryptographic keys for local development or testing without exposing sensitive data to external servers.

## How it works

- Select your desired key size (2048, 3072, or 4096 bits) and choose between the PKCS#8 or PKCS#1 private key format.
- Optionally enter a passphrase to encrypt the private key using AES-256-CBC.
- Click generate to run the cryptographic function locally in your browser and instantly view the copy-ready PEM-encoded public and private keys.

## Use cases

- Generating RSA key pairs for signing and verifying JSON Web Tokens (JWT) in web applications.
- Creating public and private key pairs to configure secure SSH access to remote servers.
- Setting up local SSL/TLS certificates for development environments requiring HTTPS.

## Frequently asked questions

### Are my generated keys secure?

Yes. The keys are generated entirely in your browser using local cryptographic APIs and are never sent to any server.

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

PKCS#8 is a modern, generic standard that supports passphrase encryption in this tool, while PKCS#1 is an older, RSA-specific format.

### Which key size should I choose?

2048 bits is the standard baseline for most applications, while 4096 bits offers stronger, long-term security at the cost of slower performance.

### Can I encrypt a PKCS#1 private key with a passphrase here?

No, passphrase encryption in this tool is only supported for the PKCS#8 format.

### What format is the generated public key?

The public key is always generated in the standard SPKI format, labeled as 'PUBLIC KEY'.

## Related tools

- [Env File Secret Rotation Planner](https://elysiatools.com/en/tools/env-file-secret-rotation-planner): Paste a .env file and get a staged secret-rotation plan. Detects database URLs, API keys, auth tokens, private keys, cloud credentials, payment keys and encryption secrets, scores each by exposure and age, and schedules them across a 4-week rotation timeline with a dual-key checklist and a generated .env.example. Optional last-rotated dates and a configurable cadence (30/90/180/365 days) drive compliance scoring.
- [AGEX Keypair Generator](https://elysiatools.com/en/tools/agex-keypair-generator): Generate an Ed25519 keypair for AGEX bundle signing and verification
- [Key Pair Generator](https://elysiatools.com/en/tools/key-pair-generator): Generate public/private key pairs for various cryptographic algorithms
- [SSH Key Pair Generator](https://elysiatools.com/en/tools/ssh-key-generator): Generate an SSH key pair (Ed25519 recommended, RSA 4096, or ECDSA P-256) with an OpenSSH-format public key ready for ~/.ssh/authorized_keys, a SHA256 fingerprint, and a PEM private key. Optional passphrase encryption. Runs locally.
- [JWT Generator](https://elysiatools.com/en/tools/jwt-generator): Generate JWT tokens with custom claims and algorithms
- [AI Prompt A/B Variant Generator](https://elysiatools.com/en/tools/ai-prompt-ab-variant-generator): Generate controlled A/B variants of a prompt across the persona, tone/style, output format, and constraints dimensions, then compare them side by side with a heuristic rubric score and a word-level diff against the baseline. A reproducible way to test how a prompt behaves under different framings before picking one for production.
- [Color Gradient Generator](https://elysiatools.com/en/tools/color-gradient-generator): Generate smooth color gradients between multiple colors with customizable steps and formats
- [Polar Area Chart Generator](https://elysiatools.com/en/tools/polar-area-chart): Generate interactive polar area charts to visualize data in circular format, perfect for comparing categories with cyclical patterns or radial distributions

## Samples

- [Android Image Processing Java Samples](https://elysiatools.com/en/samples/android-image-processing-java): Android Java image processing examples including reading/saving images, scaling, and format conversion
- [Android Image Processing Kotlin Samples](https://elysiatools.com/en/samples/android-image-processing-kotlin): Android Kotlin image processing examples including reading/saving images, scaling, and format conversion
- [Web Image Processing Python Samples](https://elysiatools.com/en/samples/web-image-processing-python): Web Python image processing examples using PIL/Pillow including reading, saving, resizing, and format conversion
- [Web Image Processing Rust Samples](https://elysiatools.com/en/samples/web-image-processing-rust): Web Rust image processing examples including image read/save, scaling, and format conversion

## Related content

- [Token, Session, and 2FA Workflow Tools](https://elysiatools.com/en/hubs/token-session-and-2fa-workflows): Debug real sign-in flows with PKCE and nonce generators, JWT and JWK inspectors, HMAC verification, OTP and TOTP testing, and auth-safe identifiers collected in one focused workflow hub.
- [Authentication, Password, and Token Security Tools](https://elysiatools.com/en/hubs/auth-token-security): Generate and validate passwords, review JWTs, compare password-hash workflows, and inspect auth-related security basics in one hub.
- [Document Encryption, Redaction, and Field Security Tools](https://elysiatools.com/en/hubs/document-field-security-workflows): Compare PDF password protection, permission control, encrypted PDF export, CSV/XLSX field encryption, AES bundles, and document redaction tools in one security workflow hub.
- [Text Redaction, Highlighting, and Presentation Formatting Tools](https://elysiatools.com/en/hubs/text-format): Compare tools for masking sensitive text, finding PII, normalizing phone numbers, highlighting phrases, centering text, and formatting diffs in one hub.
