RSA-OAEP Encrypt & Decrypt Online | PEM PKCS#8 Public Key
Encryption How It Works
This tool provides RSA-OAEP encryption and decryption using the browser's built-in
Web Crypto API. RSA-OAEP (Optimal Asymmetric Encryption Padding) is the recommended
padding scheme for new applications, replacing the deprecated PKCS#1 v1.5. The tool includes a
built-in key generator, key inspector, and PKCS#8/PKCS#1 format conversion. All cryptographic
operations run locally — your keys and data never leave your device.
RSA Key Size & Capacity
Maximum plaintext size with SHA-256 OAEP padding (key size − 66 bytes overhead):
| Key Size | Max Plaintext | Security Level | Recommended |
|---|---|---|---|
| RSA-2048 | 190 bytes | 112-bit | Minimum acceptable |
| RSA-3072 | 318 bytes | 128-bit | Recommended for most use |
| RSA-4096 | 446 bytes | 152-bit | High-security applications |
Code Examples
Encrypt and decrypt with RSA-OAEP:
// Browser — Web Crypto API RSA-OAEP
const keyPair = await crypto.subtle.generateKey(
{ name: 'RSA-OAEP', modulusLength: 2048, publicExponent: new Uint8Array([1,0,1]), hash: 'SHA-256' },
true, ['encrypt', 'decrypt']
);
const ct = await crypto.subtle.encrypt(
{ name: 'RSA-OAEP' }, keyPair.publicKey, new TextEncoder().encode('secret')
);
const pt = await crypto.subtle.decrypt(
{ name: 'RSA-OAEP' }, keyPair.privateKey, ct
);
console.log(new TextDecoder().decode(pt)); # Python — RSA-OAEP with cryptography library
from cryptography.hazmat.primitives.asymmetric import rsa, padding
from cryptography.hazmat.primitives import hashes
key = rsa.generate_private_key(public_exponent=65537, key_size=2048)
ct = key.public_key().encrypt(
b'secret',
padding.OAEP(mgf=padding.MGF1(hashes.SHA256()),
algorithm=hashes.SHA256(), label=None)
) Security Notes
- RSA-OAEP only — never use PKCS#1 v1.5 for encryption; it is vulnerable to padding oracle attacks (Bleichenbacher).
- Hybrid encryption for large data — RSA can only encrypt data smaller than key size minus padding; use RSA to wrap an AES key for bulk data.
- Hash must match — the OAEP hash algorithm must be identical between key generation and encryption/decryption.
- Key size ≥ 2048 bits — NIST recommends at least 2048-bit RSA; 3072+ for long-term security.
Related Tools
Need to generate RSA key pairs? The RSA Key Generator creates PEM-formatted keys with configurable parameters. To convert between PKCS#1 and PKCS#8 formats, try the PEM Format Converter. For hybrid encryption workflows, combine with AES Encrypt/Decrypt.
Frequently Asked Questions
How does RSA encryption work?
RSA is an asymmetric encryption algorithm that uses a pair of mathematically linked keys. The public key encrypts data, and only the corresponding private key can decrypt it. This tool uses RSA-OAEP (Optimal Asymmetric Encryption Padding), which is the recommended padding scheme for new applications because it provides provable security against chosen-ciphertext attacks.
What is the maximum data size I can encrypt with RSA?
RSA can only encrypt data smaller than the key size minus the padding overhead. For RSA-OAEP with SHA-256 and a 2048-bit key, the maximum plaintext is 190 bytes (256 - 66). For a 4096-bit key, it is 446 bytes. If you need to encrypt larger data, use RSA to encrypt a symmetric key (hybrid encryption) — this is how TLS/SSL works.
Which hash algorithm should I choose?
Use SHA-256 unless you have a specific reason to choose otherwise. It is the default for most RSA-OAEP implementations and provides a good balance of security and performance. SHA-384 and SHA-512 offer higher security margins but are slower and less commonly used. The hash must match the one used during key generation.
Can I use keys generated by other tools?
Yes, as long as the keys are in PEM format (PKCS#8 for private keys, SPKI/X.509 for public keys) and use the RSA-OAEP algorithm. Keys generated by OpenSSL, the RSA Key Generator on this site, or most standard cryptographic libraries will work. Note that RSA-PKCS#1 v1.5 keys need to be re-generated as RSA-OAEP keys.
What if my data is larger than the RSA capacity?
Use hybrid encryption: generate a random AES-256 key, encrypt your data with AES, then encrypt only the AES key with RSA. This is how TLS/SSL works — RSA protects the symmetric key, and AES handles the bulk data efficiently.
Privacy: This tool runs entirely in your browser — nothing is uploaded or stored. · Disclaimer: For educational purposes only. Not professional security advice.
More in Encryption
AES Encrypt/Decrypt
Encrypt and decrypt with AES-128/192/256 online. GCM, CTR, and OpenSSL-compatible CBC modes. Passphrase or raw key, custom IV.
ChaCha20 / Salsa20 Encrypt/Decrypt
Encrypt and decrypt with ChaCha20, XChaCha20, ChaCha20-Poly1305 (AEAD), or Salsa20 online. Passphrase mode with PBKDF2 key derivation.
DES Encrypt/Decrypt
Encrypt and decrypt with DES or 3DES (Triple DES) online. CBC/ECB/CFB/OFB modes, PKCS7/NoPadding, OpenSSL compatible.
XOR Encrypt/Decrypt
Encrypt and decrypt with XOR cipher online. Text/Hex/Base64 formats, visual XOR table, brute-force key breaking, auto-solve.
JWE Encrypt / Decrypt
Encrypt and decrypt JWE (JSON Web Encryption) tokens online. RSA-OAEP, AES key wrap, PBES2 password-based key management, A128GCM/A256GCM.
Blowfish Encrypt/Decrypt
Encrypt and decrypt with Blowfish online. 5 cipher modes, 5 paddings, GBK/UTF-16 support, OpenSSL passphrase compatible.
PGP Encrypt / Decrypt
Encrypt, decrypt, sign, and verify with OpenPGP online. Public key and password modes, built-in key generator, GnuPG compatible.