RSA Decryption with a Private Key
Decrypt RSA ciphertext (Base64 or hex) with a PEM private key using RSA-OAEP SHA-256, OAEP SHA-1 or PKCS#1 v1.5. Clear errors for wrong key or padding.
OAEP is the recommended padding. MGF1 uses the same hash, like Web Crypto and openssl pkeyutl -pkeyopt rsa_oaep_md.
Runs entirely in your browser. Your data is never uploaded.
What is RSA Decryption?
Decrypts RSA ciphertext with your private key in PEM format (PKCS#8 BEGIN PRIVATE KEY or PKCS#1 BEGIN RSA PRIVATE KEY). It supports RSA-OAEP with SHA-256 or SHA-1 and legacy PKCS#1 v1.5 padding, matching OpenSSL, Web Crypto, Java and Node.js output.
How to use RSA Decryption
- Paste the Private key (PEM) (unencrypted), or click Generate a test key pair (2048-bit) to experiment.
- Select the Padding that was used for encryption.
- Paste the Ciphertext and choose Base64 or Hex as its encoding.
- Click Decrypt; switch the output to Hex if the plaintext is binary (e.g. an AES key).
Example
Ciphertext from Node.js `crypto.publicEncrypt` (RSA-OAEP, oaepHash sha256) of "Hello RSA", with the matching 2048-bit PKCS#8 private key
Hello RSA
When to use RSA Decryption
Use it to check ciphertext produced by your own code, to decrypt test data, or to verify interoperability between platforms. Avoid pasting real production private keys into a browser; use test keys. Password-protected private keys must be exported without a passphrase first.
How RSA Decryption works
The private exponent recovers the padded message m = cᵈ mod n (with CRT optimisation), then the padding is removed and checked: OAEP verifies the MGF1 mask and label hash for the chosen SHA-256 or SHA-1, PKCS#1 v1.5 verifies the 00 02 header and separator. The ciphertext must be exactly as long as the modulus (256 bytes for 2048-bit keys); any mismatch in key, padding or hash causes a decryption error rather than wrong output.
Common Use Cases
- Verify that browser-side RSA-OAEP output decrypts with your server key
- Decrypt an AES key wrapped with RSA in a hybrid-encryption test
- Diagnose OAEP SHA-1 vs SHA-256 mismatches between Java and Node.js
- Decrypt PKCS#1 v1.5 data from a legacy system
Security Note
Keys and messages are processed only in your browser. Do not paste production private keys into any website you do not control – generate a test key pair instead.
FAQs
"Decryption failed" – what is wrong?
Usually the padding or OAEP hash does not match (SHA-1 vs SHA-256), the ciphertext belongs to a different key pair, or it was damaged while copying. Try the other OAEP hash first.
My key starts with BEGIN ENCRYPTED PRIVATE KEY.
Password-protected keys are not supported. Convert a test copy with openssl pkey -in key.pem -out plain.pem and handle the unencrypted key carefully.
The ciphertext length error says it must be 256 bytes.
RSA ciphertext always has the modulus length. Check that you pasted the whole Base64 string and selected the right input encoding (Base64 vs Hex).