# RSA Decrypt

Decrypt RSA ciphertext with a PEM private key using OAEP or PKCS#1 v1.5 padding. Supports base64/hex input and UTF-8/hex/base64 output.

## Run it

- **CLI:** `gizza tool rsa-decrypt "Paste the RSA ciphertext, e.g. Q1rN...AA==" 'private_key=-----BEGIN PRIVATE KEY-----
...
-----END PRIVATE KEY-----'`
- **Web:** https://gizza.ai/tools/rsa-decrypt/
- **Agents:** machine-readable descriptor (parameters JSON Schema) at https://gizza.ai/tools/rsa-decrypt/tool.json

## Inputs

- `ciphertext` — Ciphertext (base64 or hex) _(field)_
- `private_key` — Private key PEM _(field)_
- `passphrase` — Key passphrase (optional) _(field)_
- `padding` — Padding _(field)_
- `hash` — OAEP hash _(field)_
- `ciphertext_encoding` — Ciphertext encoding _(field)_
- `output_encoding` — Plaintext output _(field)_

## Output

- Plaintext (text)

## Query parameters

Open the tool pre-filled and auto-run via URL:

- `ciphertext` — Ciphertext (base64 or hex)
- `private_key` — Private key PEM
- `passphrase` — Key passphrase (optional)
- `padding` — Padding
- `hash` — OAEP hash
- `ciphertext_encoding` — Ciphertext encoding
- `output_encoding` — Plaintext output

Example: `https://gizza.ai/tools/rsa-decrypt/?ciphertext=Paste%20the%20RSA%20ciphertext%2C%20e.g.%20Q1rN...AA%3D%3D&private_key=-----BEGIN%20PRIVATE%20KEY-----%0A...%0A-----END%20PRIVATE%20KEY-----&passphrase=Leave%20blank%20for%20an%20unencrypted%20private%20key&padding=oaep&hash=sha256&ciphertext_encoding=auto&output_encoding=utf8`

---

## About this tool

RSA Decrypt recovers the plaintext from a single RSA ciphertext block with the matching private key.
Use it when a message or wrapped symmetric key was encrypted with RSA-OAEP or legacy RSAES-PKCS1-v1_5
and you need to verify the payload locally. Paste a PEM private key, paste the base64 or hex
ciphertext, choose the padding and OAEP hash that the sender used, and select whether the recovered
bytes should be rendered as UTF-8 text, hex, or base64.

The private key and ciphertext are processed in WebAssembly; the tool does not upload them. OAEP
with SHA-256 is the default because it is the modern RSA encryption mode. PKCS#1 v1.5 is included
only for compatibility with old systems. RSA can decrypt only one key-sized block, so large messages
should be handled with hybrid encryption: RSA decrypts a small random content key, then a symmetric
cipher decrypts the bulk data.

### Worked example

The bundled example ciphertext was encrypted with OAEP-SHA256 to the throwaway fixture key used by
this repository's tests. Paste that fixture private key, select `padding = oaep`, `hash = sha256`,
`ciphertext_encoding = base64`, and `output_encoding = utf8`; the plaintext is `hello from
rsa-decrypt`. For binary payloads, switch `output_encoding` to `hex` or `base64` instead of trying
to force the bytes into text.

### Limits and edge cases

- The ciphertext must be exactly one RSA block: 256 bytes for a 2048-bit key, 512 bytes for a
  4096-bit key, and so on.
- OAEP decryption succeeds only when the hash setting matches the sender's OAEP/MGF1 hash.
- PKCS#8 and PKCS#1 PEM private keys are accepted. Encrypted PKCS#8 keys require a passphrase;
  legacy OpenSSL `Proc-Type: 4,ENCRYPTED` PEM keys must be converted to PKCS#8 first.
- If the decrypted bytes are not valid UTF-8, choose hex or base64 output.
- This tool does not generate keys, encrypt messages, or perform signatures. Use the neighboring RSA
  encrypt/sign/verify tools for those surfaces.

## FAQ

<details>
<summary>Why does RSA decryption fail when the private key is correct?</summary>

RSA encryption parameters must match exactly. Check the padding (`oaep` vs `pkcs1v15`), the OAEP
hash (`sha256`, `sha384`, or `sha512`), the ciphertext encoding, and whether the ciphertext was
truncated or copied with whitespace changes. A ciphertext encrypted to a different public key cannot
be decrypted by this private key.

</details>

<details>
<summary>Can I decrypt a whole file with this?</summary>

Not directly. RSA encryption is for small payloads such as a random AES key or short secret. A file
should be encrypted with a symmetric cipher, with RSA used only to unwrap the symmetric key. If you
paste a full file ciphertext here it will usually be much longer than the RSA key size and the tool
will reject it.

</details>

<details>
<summary>Which padding should I choose?</summary>

Use OAEP when you control both sides or know the sender used a modern default. Choose PKCS#1 v1.5
only for compatibility with older systems that explicitly say they used RSAES-PKCS1-v1_5. The
selected padding must match the original encryption mode; there is no safe auto-detection.

</details>

<details>
<summary>Is it safe to paste a private key here?</summary>

The decryption runs locally in WebAssembly and the key is not uploaded by this page. You should still
use a throwaway key for tests when possible, avoid pasting production keys on shared machines, and
clear the tab after use.

</details>

## Related tools

- [AES-CMAC Generator](https://gizza.ai/tools/cmac-generate/): Generate an AES-CMAC (NIST SP 800-38B / RFC 4493) of any message and key in your browser — AES-128/192/256 by key length, hex or base64 output. Free and private.
- [Hash All Generator](https://gizza.ai/tools/hash-all/): Hash text with every common algorithm at once — MD5, SHA-1, SHA-256/512, SHA-3, BLAKE3, RIPEMD-160, CRC-32 and more — free and private in your browser.
- [Text Hash Generator](https://gizza.ai/tools/hash-text/): Generate MD5, SHA-1, SHA-256/512, SHA-3, BLAKE2 or BLAKE3 hashes of any text in your browser, with hex or base64 output. Free, private, nothing uploaded.
- [HMAC Generator](https://gizza.ai/tools/hmac-generate/): Generate an HMAC of any message and secret key in your browser — HMAC-SHA256, SHA-1, SHA-512, SHA-3 or MD5, hex or base64 output. Free and private.
- [Keccak-256 Hash Generator](https://gizza.ai/tools/keccak-hash/): Compute the original Keccak-256 or Keccak-512 hash of any text in your browser — the exact hash Ethereum uses, not FIPS SHA-3. Free and private.
