RSA Encrypt / Decrypt

See public-key encryption in action: anyone can encrypt with the public key, only the private key can decrypt.

Never paste a real production private key into a website. This page runs entirely in your browser, but for real secrets the safest place is your own machine. Use the sample keys to learn and test.

● 🔒 Your data is processed locally in your browser with the Web Crypto API and is never uploaded to our servers.

How to encrypt and decrypt with RSA

  1. Click Generate a sample 2048-bit key pair, or paste your own keys in PEM format.
  2. Type a message and click Encrypt with the public key. The result appears in Base64.
  3. Click Decrypt: the private key recovers the original message.

Encrypt the same message twice: the results are different each time. That's normal — RSA-OAEP adds random padding so that identical messages can't be recognized.

How RSA works, simply

RSA uses a pair of mathematically linked keys. The public key can be shared with anyone: it only encrypts. The private key stays secret: only it can decrypt what the public key encrypted. Its security relies on the difficulty of factoring a very large number (the product of two primes of about 300 digits each for a 2048-bit key).

KeyUsed toShare it?
Public key (BEGIN PUBLIC KEY)Encrypt, verify signaturesYes, freely
Private key (BEGIN PRIVATE KEY)Decrypt, signNever

Message size limit and hybrid encryption

RSA can only encrypt short messages: 190 bytes with a 2048-bit key (RSA-OAEP with SHA-256), 446 bytes with a 4096-bit key. Real systems use hybrid encryption: a random AES key encrypts the data, and RSA encrypts only that AES key. That's how HTTPS, PGP and encrypted email work. For large data, use AES Encrypt.

Key sizes

Using OpenSSL keys

The tool accepts PKCS#8 (“BEGIN PRIVATE KEY”) and SPKI (“BEGIN PUBLIC KEY”) PEM keys. Convert an older “BEGIN RSA PRIVATE KEY” file with openssl pkcs8 -topk8 -nocrypt -in key.pem. Generate a new pair with openssl genpkey -algorithm RSA -pkeyopt rsa_keygen_bits:2048.

FAQ

Is it safe to paste a private key here?

Everything runs in your browser with the Web Crypto API and nothing is uploaded — but never paste a real production private key into any website. Use the sample keys to learn and test.

How do I sign a message instead?

Use RSA Sign / Verify. To create keys to download, use the RSA Key Pair Generator.

Why does decryption fail?

Usually the private key doesn't match the public key used to encrypt, or the Base64 text was cut when copied.