Toolonit
  1. Home
  2. Encrypt
  3. RSA Encrypt / Decrypt

RSA Encryption & Decryption

Encrypt with an RSA public key and decrypt with the private key (OAEP or PKCS#1 v1.5).

Padding

Decrypt with the same padding that was used to encrypt. OAEP with SHA-256 is the modern default; PKCS#1 v1.5 only for older systems.

Output as
Decrypt this with OpenSSL (the .bin file):
openssl pkeyutl -decrypt -inkey private.pem -in ciphertext.bin -pkeyopt rsa_padding_mode:oaep -pkeyopt rsa_oaep_md:sha256

Encrypt a short secret with someone's RSA public key (or their certificate) so only the holder of the private key can read it, or decrypt a ciphertext with your private key. Choose OAEP with SHA-256 (recommended), OAEP with SHA-1 or PKCS#1 v1.5; the result is Base64 or hex and works with OpenSSL. Everything runs in your browser, so keys and messages never leave your device; it's free and needs no sign-up.

How to encrypt and decrypt with RSA

  1. Choose Encrypt or Decrypt, then paste the key or open a key file: a public key or certificate to encrypt, the private key (PKCS#8 or PKCS#1) to decrypt.
  2. Pick the padding: OAEP · SHA-256 unless the other side needs something else.
  3. Type the message, or paste the ciphertext as Base64 or hex. The result appears as you type.
  4. Copy the result, or download the ciphertext as a .bin file for OpenSSL.

Features

  • Encrypt with a public key, a certificate or the public half of a private key; decrypt with the private key
  • OAEP with SHA-256 (default), OAEP with SHA-1, or PKCS#1 v1.5
  • Keys as PEM or DER: SPKI, PKCS#1, PKCS#8 and X.509 certificates, up to 16384 bits
  • Ciphertext as Base64 or hex, or a .bin file; decrypts pasted Base64 or hex, or an opened .bin file
  • Shows how many bytes the key and padding can encrypt, and the matching openssl pkeyutl command
  • Runs in a WebAssembly worker in your browser

Is it private?

Yes. Encryption and decryption run in your browser, in a WebAssembly worker; keys, messages and ciphertexts are never uploaded or stored.

Frequently asked questions

How long can the message be?

RSA encrypts one block. With a 2048-bit key that is up to 190 bytes with OAEP SHA-256, 214 with OAEP SHA-1 and 245 with PKCS#1 v1.5; bigger keys allow more. For anything longer, encrypt the data with a symmetric cipher, or use File Encryption.

Why is the ciphertext different every time?

Every padding adds random bytes before encrypting, so the same message gives a new ciphertext each time. That is by design, and each of them decrypts to the same message.

Does it work with OpenSSL?

Yes. A ciphertext made here decrypts with openssl pkeyutl -decrypt -inkey private.pem -pkeyopt rsa_padding_mode:oaep -pkeyopt rsa_oaep_md:sha256 (or rsa_padding_mode:pkcs1), and ciphertexts made with openssl pkeyutl -encrypt decrypt here. Use the same padding on both sides.

Which key formats can I use?

PEM public keys (BEGIN PUBLIC KEY or BEGIN RSA PUBLIC KEY), certificates, and unencrypted private keys in PKCS#8 (BEGIN PRIVATE KEY) or PKCS#1 (BEGIN RSA PRIVATE KEY), also as DER files. Password-protected and OpenSSH keys need converting first; the tool says how.

Why does decryption fail?

Usually the padding or the key. Decrypt with the same padding that was used to encrypt, and with the private key that belongs to the public key used; the tool doesn't tell these apart, on purpose, so try the other paddings. A ciphertext is always as long as the key (256 bytes for a 2048-bit key), so a shorter one was cut off when copied.

Related tools