# RSA Encrypt / Decrypt

Encrypt text with an RSA public key or decrypt ciphertext with the matching private key, using OAEP padding (SHA-1 or SHA-256). Handles long messages by chunking. Keys and data stay local. PKCS#1 v1.5 is intentionally not offered (Node disables it for decryption due to Bleichenbacher attacks).

> Canonical page: https://elysiatools.com/en/tools/rsa-encrypt-decrypt

- **Category:** Security

- **Keywords:** rsa, encrypt, decrypt, oaep, pkcs1, asymmetric, cryptography, public key, private key, cipher

## Overview

A practical RSA OAEP encryption/decryption tool.

- **Mode**: encrypt (public key → ciphertext) or decrypt (private key → plaintext).
- **Padding**: **OAEP** (Optimal Asymmetric Encryption Padding) with SHA-1 or SHA-256 hash. OAEP is the modern, semantically-secure scheme recommended for new RSA encryption. PKCS#1 v1.5 is intentionally omitted — it is vulnerable to Bleichenbacher padding-oracle attacks and Node.js refuses to decrypt with it.
- **Chunking**: RSA can only encrypt a small block at once (key bytes − 2×hash size − 2). Messages longer than that are split into blocks, each encrypted separately, and the ciphertexts concatenated. Decryption splits on the modulus boundary and reverses it.
- **Encoding**: ciphertext is hex or base64.

Why OAEP max block = k − 2hLen − 2: OAEP adds a hash-length seed and label hash plus 2 delimiter bytes, so the usable payload per block shrinks accordingly.

Use cases: end-to-end message encryption demos, encrypting a small payload to someone's public key, learning RSA in practice. Everything runs locally.

## Inputs

- **Mode** (select)
- **Public key (PEM)** (textarea): -----BEGIN PUBLIC KEY----- ... -----END PUBLIC KEY-----
- **Private key (PEM)** (textarea): -----BEGIN PRIVATE KEY----- ... -----END PRIVATE KEY-----
- **Private key passphrase (if encrypted)** (text): Only if the private key is passphrase-protected…
- **Message (plaintext)** (textarea): The text to encrypt…
- **Ciphertext (hex or base64)** (textarea): Paste the ciphertext produced by this tool…
- **OAEP hash** (select)
- **Ciphertext encoding** (select)

## When to use

- When you need to encrypt a sensitive configuration value or API key using a recipient's RSA public key before sharing it.
- When you need to decrypt a ciphertext payload locally using your passphrase-protected or unencrypted RSA private key.
- When testing asymmetric encryption workflows or verifying RSA key pairs using secure OAEP padding configurations.

## How it works

- Select the operation mode (encrypt with public key or decrypt with private key) and paste your PEM-formatted RSA key.
- Choose the OAEP hash algorithm (SHA-256 or SHA-1) and the preferred ciphertext encoding format (Hex or Base64).
- Input your plaintext message or ciphertext; the tool automatically chunks data exceeding the RSA block limit and processes it locally.

## Use cases

- Encrypting database credentials with a production public key before committing them to a repository.
- Decrypting automated alert payloads sent by external systems that encrypt data using your public key.
- Verifying that a generated RSA public/private key pair functions correctly with OAEP padding.

## Frequently asked questions

### Why is PKCS#1 v1.5 padding not supported?

PKCS#1 v1.5 is vulnerable to Bleichenbacher padding-oracle attacks and is disabled for decryption in modern runtimes like Node.js.

### How does the tool handle messages that exceed the RSA block size limit?

It automatically splits the message into smaller chunks, encrypts or decrypts each block separately, and concatenates the results.

### Are my private keys or messages uploaded to a server?

No. All encryption and decryption operations are performed locally in your browser, ensuring your keys and data never leave your device.

### What is the maximum payload size for a single RSA block?

The maximum size is determined by the key size in bytes minus two times the hash length minus two (k - 2hLen - 2).

### Can I decrypt a private key that is protected by a passphrase?

Yes, you can provide the passphrase in the designated input field to decrypt passphrase-protected PEM private keys.

## Related tools

- [Hash Algorithm Comparator](https://elysiatools.com/en/tools/hash-algorithm-comparator): Hash the same input with MD5, SHA-1, SHA-256, SHA-512, BLAKE2b, and BLAKE3 at the same time and compare them side by side: output length, hex/Base64 digest, security status (broken / modern), and a relative speed benchmark. Great for teaching, choosing a hashing algorithm, or sanity-checking checksums.
- [PKCE Code Verifier & Challenge Generator](https://elysiatools.com/en/tools/pkce-code-verifier-generator): Generate, validate and verify OAuth2 / OIDC PKCE (RFC 7636) code_verifier and S256 code_challenge pairs. Three modes: (1) generate a fresh verifier + challenge from cryptographically secure random bytes at 256/384/512/768-bit entropy, (2) audit a verifier you already have against the RFC — length (43–128), charset \[A-Za-z0-9-._~\] and ≥256-bit entropy, and (3) verify a verifier/challenge pair by recomputing BASE64URL(SHA256(verifier)). Optionally build the full authorization-request URL and token-exchange body. Complements the generic nonce-generator (which only emits a verifier+challenge pair) with RFC-compliance auditing and pair verification.
- [Excel Field-Level Decryptor](https://elysiatools.com/en/tools/excel-field-decryptor): Decrypt specific fields in Excel files using various decryption methods to restore encrypted information
- [Excel Field-Level Encryptor](https://elysiatools.com/en/tools/excel-field-encryptor): Encrypt specific fields in Excel files using various encryption methods to protect sensitive information
- [Text Hash Generator](https://elysiatools.com/en/tools/text-hash-generator): Compute MD5, SHA-1, SHA-256, SHA-512, and CRC-32 hashes of any text in one shot. Get both hex and Base64 digests over the UTF-8 encoding.
- [CRC32 Checksum](https://elysiatools.com/en/tools/crc32-checksum): Compute the CRC32 checksum (IEEE 802.3 polynomial) of any text or raw bytes. Output as hex, decimal or binary. Accepts plain text (UTF-8) or raw bytes via hex/base64 input.
- [Ed25519 / X25519 Keygen and Signature Verifier](https://elysiatools.com/en/tools/ed25519-x25519-keygen-signature-verifier): Generate Ed25519 or X25519 keypairs from random or deterministic seed text, then sign or verify messages
- [Barcode Batch Generator](https://elysiatools.com/en/tools/barcode-batch-generator): Batch generate Code 128, EAN-13, UPC-A, ITF-14, QR Code, and Data Matrix outputs from CSV or multiline text

## Samples

- [Copyright-Free MP3 Audio Samples](https://elysiatools.com/en/samples/mp3-samples): Collection of royalty-free audio samples for testing and development purposes including nature sounds, meditation music, and ambient audio
- [Web Image Processing Python Samples](https://elysiatools.com/en/samples/web-image-processing-python): Web Python image processing examples using PIL/Pillow including reading, saving, resizing, and format conversion
- [Android Image Processing Java Samples](https://elysiatools.com/en/samples/android-image-processing-java): Android Java image processing examples including reading/saving images, scaling, and format conversion
- [Android Image Processing Kotlin Samples](https://elysiatools.com/en/samples/android-image-processing-kotlin): Android Kotlin image processing examples including reading/saving images, scaling, and format conversion

## Related content

- [Text Case, Encoding, and Normalization Conversion Tools](https://elysiatools.com/en/hubs/text-convert): Compare text case conversion, character-width conversion, encoding conversion, quoted-printable handling, and inline text normalization tools in one hub.
- [Text Tools](https://elysiatools.com/en/hubs/text-utility): Explore 33 text tools for utility workflows and compare closely related utilities quickly.
- [Text Analysis, Readability, and Content Inspection Tools](https://elysiatools.com/en/hubs/text-analyze): Compare text statistics, language detection, readability scoring, sentiment analysis, moderation review, and pattern analysis tools in one hub.
- [Text Redaction, Highlighting, and Presentation Formatting Tools](https://elysiatools.com/en/hubs/text-format): Compare tools for masking sensitive text, finding PII, normalizing phone numbers, highlighting phrases, centering text, and formatting diffs in one hub.
