Logo

MonoCalc

/

RSA Encrypt / Decrypt

Encode/Decode

Key Strength

Acceptable

About This Tool

🔐 RSA Encrypt / Decrypt – Browser-Based RSA Tool

RSA (Rivest–Shamir–Adleman) is the world's most widely used public-key cryptosystem. Unlike symmetric ciphers such as AES, RSA uses a mathematically linked key pair: a public key for encryption and a private key for decryption. Anyone can encrypt a message using your public key, but only you — holding the private key — can decrypt it. This tool implements RSA-OAEP encryption and decryption entirely in your browser using the native Web Crypto API, with no data ever leaving your device.

🔑 How RSA Encryption Works

RSA security is founded on the computational difficulty of factoring the product of two large prime numbers. During key generation, two large primes p and q are chosen, and their product n = p × q forms the modulus. The public key consists of (n, e) where e = 65537 is the standard public exponent. The private key contains (n, d) where d is the modular inverse of e.

Encryption computes: C = M^e mod n — and decryption reverses it: M = C^d mod n. In practice, raw RSA is never used directly; a padding scheme (OAEP) is always applied to ensure semantic security.

⚙️ RSA-OAEP Padding

OAEP (Optimal Asymmetric Encryption Padding) is the recommended padding scheme for RSA encryption, standardized in PKCS#1 v2.1. It incorporates a random seed and a hash function (SHA-256 by default) to add randomness to the ciphertext — meaning the same plaintext encrypted twice will produce different ciphertexts. This property, called semantic security, prevents dictionary attacks and distinguishability attacks.

The maximum plaintext size with RSA-OAEP depends on the key size and the hash function: maxBytes = keyBytes − 2 × hashBytes − 2. For a 2048-bit key with SHA-256: 256 − 64 − 2 = 190 bytes. RSA is designed for small payloads such as symmetric keys — for large data, use hybrid encryption (encrypt a random AES key with RSA, then encrypt the data with AES-GCM).

📏 Key Sizes and Security

Key SizeSecurity LevelMax Plaintext (SHA-256)Recommendation
1024 bits~80 bits62 bytes⚠️ Deprecated — do not use
2048 bits~112 bits190 bytes✅ Minimum for production
3072 bits~128 bits318 bytes✅ Strong — recommended
4096 bits~140 bits446 bytes✅ High assurance / long-term

🔍 PEM Key Format

RSA keys are most commonly distributed in PEM (Privacy Enhanced Mail) format — a Base64-encoded DER structure wrapped in human-readable headers. Public keys use the SPKI (SubjectPublicKeyInfo) format (-----BEGIN PUBLIC KEY-----), while private keys use PKCS#8 format (-----BEGIN PRIVATE KEY-----). Both are the standard formats used by OpenSSL, TLS certificates, and SSH key infrastructure.

🛡️ Security Notes

  • All operations run in your browser. No keys, plaintext, or ciphertext are transmitted to any server. The Web Crypto API uses your browser's native cryptographic implementation.
  • Never share your private key. The private key is the only secret in RSA. Anyone who obtains your private key can decrypt all messages encrypted to your public key.
  • Use this tool for testing and learning. For production systems, use battle-tested cryptographic libraries (OpenSSL, libsodium, Web Crypto in a controlled environment) and follow your organization's key management policies.
  • RSA-OAEP is preferred over PKCS#1 v1.5. PKCS#1 v1.5 is vulnerable to Bleichenbacher's adaptive chosen-ciphertext attack. The Web Crypto API supports only RSA-OAEP for this reason.

📋 Typical Use Cases

  • Testing RSA key pairs generated by OpenSSL or other tools
  • Encrypting short secrets (API tokens, passwords, symmetric keys) for secure transmission
  • Learning asymmetric cryptography concepts in a hands-on environment
  • Verifying that a public/private key pair is correctly matched before deployment
  • Inspecting PEM key metadata: modulus length, public exponent, fingerprint

Frequently Asked Questions

Is the RSA Encrypt / Decrypt free?

Yes, RSA Encrypt / Decrypt is totally free :)

Can I use the RSA Encrypt / Decrypt offline?

Yes, you can install the webapp as PWA.

Is it safe to use RSA Encrypt / Decrypt?

Yes, any data related to RSA Encrypt / Decrypt only stored in your browser (if storage required). You can simply clear browser cache to clear all the stored data. We do not store any data on server.

How does this RSA encrypt/decrypt tool work?

This tool uses the browser-native Web Crypto API (window.crypto.subtle) to perform all RSA operations entirely on your device. You can generate key pairs, encrypt plaintext with an RSA public key using RSA-OAEP padding, decrypt ciphertext with the matching private key, inspect PEM key metadata, and run round-trip verification — all without transmitting any data to a server.

What is RSA-OAEP and why is it recommended over PKCS#1 v1.5?

RSA-OAEP (Optimal Asymmetric Encryption Padding) is the modern, secure padding scheme for RSA encryption. It adds randomized padding with a hash function to prevent chosen-ciphertext attacks. PKCS#1 v1.5 is an older scheme that is vulnerable to Bleichenbacher's attack if error messages are not carefully controlled. For new applications, always use RSA-OAEP with SHA-256.

What key size should I use — 1024, 2048, or 4096 bits?

2048-bit keys are the current minimum recommendation for production use. 4096-bit keys provide a higher security margin at the cost of slower operations and are recommended for long-term security. 1024-bit keys are considered weak and are deprecated — this tool warns you when generating or using sub-2048-bit keys.

What is the maximum plaintext size I can encrypt with RSA?

RSA-OAEP with SHA-256 on a 2048-bit key can encrypt at most 190 bytes of plaintext (modulusBytes − 2×hashBytes − 2 = 256 − 64 − 2 = 190). For a 4096-bit key this rises to 446 bytes. RSA is not designed for large data — for that, use hybrid encryption (encrypt a random AES key with RSA, then encrypt the data with AES).

Is my private key safe when using this tool?

All cryptographic operations run entirely in your browser using the Web Crypto API — no keys or plaintext are ever transmitted to any server. However, avoid entering real production private keys into any online tool. This tool is designed for learning, testing, and development purposes.

Why does RSA produce different ciphertext for the same plaintext?

RSA-OAEP adds a random seed during padding before encryption, so the same plaintext encrypted with the same key produces a different ciphertext every time. This is intentional and is a security property — it prevents attackers from building a dictionary of known plaintext→ciphertext mappings.