Skip to main content
NyankoTools

RSA Encrypt & Decrypt (RSA-OAEP)

Encrypts text with an RSA public key (PEM) using RSA-OAEP into Base64, and decrypts it with the matching private key (PEM). It uses the browser built-in Web Crypto API and everything stays in your browser. Your text and keys are never sent to a server. Create a key pair with the Key Pair Generator. To encrypt with a password instead, use the Text Encryptor & Decryptor (AES).

🔒 Runs in your browser · Your data is never sent to a server

How to use

  1. Choose "Encrypt" or "Decrypt".
  2. Paste a public key (to encrypt) or a private key (to decrypt) in PEM into the key field.
  3. Enter the text (the ciphertext when decrypting) and press "Encrypt" or "Decrypt".
  4. Press "Copy" to copy the result.

Notes

  • The plaintext limit is key bits ÷ 8 − 66 bytes (190 bytes for RSA-2048, 318 for 3072, 446 for 4096). Japanese characters count as 3 bytes each. For longer data, the usual approach is to encrypt it with AES and encrypt only the AES key with RSA (hybrid encryption).
  • Supported keys are RSA public keys (BEGIN PUBLIC KEY, SPKI) and private keys (BEGIN PRIVATE KEY, PKCS#8). The OAEP hash is fixed to SHA-256, so ciphertext from other tools using SHA-1 or another setting may not decrypt.
  • Never share a private key. Avoid entering a private key used in production; use throwaway keys for testing. What you enter stays on this page and is neither sent nor stored.
  • OAEP adds random data on every encryption, so the same input gives a different ciphertext each time. All of them decrypt with the private key.

Glossary

RSA-OAEP

RSA encryption combined with OAEP padding. Random data is mixed in, so the same text encrypts differently every time, which makes it more secure.

Public key and private key

The public key only encrypts and can be shared freely. The private key decrypts and must be kept by its owner alone.

PEM (SPKI, PKCS#8)

A Base64 text format for keys. Public keys start with "BEGIN PUBLIC KEY" (SPKI) and private keys with "BEGIN PRIVATE KEY" (PKCS#8).

FAQ

Why is there a limit on how much text I can encrypt?

RSA cannot encrypt more data than fits in the key, and OAEP padding takes part of that space. With SHA-256 OAEP the limit is key bits ÷ 8 − 66 bytes, which is 190 bytes for RSA-2048. For longer data, encrypt it with AES and encrypt only the AES key with RSA.

Why do I get "needs a public key" or "needs a private key"?

Encryption uses a public key (BEGIN PUBLIC KEY) and decryption uses a private key (BEGIN PRIVATE KEY). The error appears when the mode and the type of key are swapped.

Which key formats are supported?

RSA public keys (SPKI, BEGIN PUBLIC KEY) and private keys (PKCS#8, BEGIN PRIVATE KEY) in PEM. "BEGIN RSA PRIVATE KEY" (PKCS#1) and EC or Ed25519 keys are not supported. RSA keys made with the Key Pair Generator work as they are.

Can I decrypt ciphertext made by OpenSSL or other tools?

Yes, if it was made with OAEP using SHA-256 (and MGF1 with SHA-256) and is Base64-encoded. Ciphertext made with SHA-1 or PKCS#1 v1.5 padding cannot be decrypted.

Why does the same text encrypt to a different result each time?

OAEP mixes in random data on every encryption, which is expected. Every result decrypts with the same private key.

Share this page

↑↓ Select Enter Open Esc Close