b2KIT

RSA Key Pair Generator

Generate RSA-2048, RSA-3072, or RSA-4096 key pairs in PEM format for signing and encryption, entirely in-browser.

Tested tool guide Tested browser tools Checked August 16, 2026

What RSA Key Pair Generator does, with a checked example

Two very different files come out of this button: a short public key you can hand to anyone, and a long private key that must never leave your machine. Both are PEM text blocks you can paste into servers, apps, and config files, and the whole job runs in the browser, so no key material is ever uploaded. The recurring surprise is the direction of no-return: the public key cannot be reversed into the private key, so losing the private key is permanent - no reset, no recovery.

Worked example

A concrete input and expected output from the current implementation.

Input

Select 2048-bit and click Generate. There is no text to type - the tool supplies the randomness itself.

Expected output

-----BEGIN PUBLIC KEY-----
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8A
<360 more base64 characters encoding the generated modulus and the exponent 65537, wrapped at 64 per line>
-----END PUBLIC KEY-----

The example elides the middle of the body; the saved file frames the full base64 between two boundary lines, in rows of at most 64 characters.

The first base64 line is fixed: it encodes the 24-byte DER header shared by every RSA-2048 public key in this format - the SubjectPublicKeyInfo structure, the rsaEncryption identifier (1.2.840.113549.1.1.1), and the bit-string header. The remainder encodes the random modulus (a 257-byte DER integer including its leading zero) and the exponent 65537, so the body changes on every generation and cannot be predicted.

How the result is produced

1

What the PEM blocks contain

PEM is plain ASCII: a header line, base64 text, and a footer line. The public key wraps a SubjectPublicKeyInfo structure carrying the modulus n and the public exponent e, usually 65537. The private key wraps the same modulus plus the private exponent and the two secret primes. The header line - BEGIN PUBLIC KEY, BEGIN PRIVATE KEY, or BEGIN RSA PRIVATE KEY - tells you which structure is inside.

2

Why the two keys are a pair

RSA's security rests on a one-way computation: the modulus n is the product of two large primes p and q, and finding p and q from n is considered infeasible at these sizes. Data encrypted with the public key can only be decrypted with the private key, and a signature made with the private key verifies with the public key. Generation starts by picking those two primes at random.

Good uses

  • Registering a public key with a service. Cloud providers, certificate authorities, and mutual-TLS setups ask you to paste the public key PEM while the private key stays on your machine.
  • Encrypting files or backups for your eyes only. Encrypt with the public key, and only the holder of the private key can decrypt, which suits storage you do not fully trust.
  • Creating a throwaway pair for development. Testing OpenSSL, client certificates in curl, or a crypto library without touching your real credentials.

Limits and checks

  • Losing the private key is unrecoverable. The public key cannot be inverted, and the tool keeps no escrow, so nothing can recreate a lost key. Copy it to secure storage before you rely on it.
  • Header lines identify the format. A PKCS#1 private key starts with BEGIN RSA PRIVATE KEY, a PKCS#8 one with BEGIN PRIVATE KEY, and some tools accept only one. OpenSSL converts between them, but check what your target expects before pasting.
  • RSA encrypts only small messages. A 2048-bit key fits at most 245 bytes with PKCS#1 v1.5 padding, or 190 bytes with OAEP and SHA-256, so real systems use RSA to encrypt a random session key and symmetric encryption for the data itself.

Common questions

Can I use this pair for SSH?

Only with conversion. OpenSSH wants its own format, not PEM: convert the public key with ssh-keygen -i -m PKCS8 -f key.pem, or just generate the pair with ssh-keygen in the first place. This tool's PEM output fits OpenSSL, TLS, and cloud workflows directly.

Is 4096 bits always better than 2048?

Not automatically. Larger keys make factoring the modulus harder, but 2048-bit RSA is not known to be broken, and NIST's SP 800-57 Part 1 rates it acceptable through 2030, recommending 3072-bit for use beyond that. Bigger keys are slower to generate and slower at every operation, so size them to how long the key must stay strong.

References and verification

The example and behavioral notes were checked against the browser implementation. Standards and primary references below define the relevant format, formula, or platform behavior.

Related Tools