RSA-OAEP Encrypt & Decrypt Online | PEM PKCS#8 Public Key

Encryption
100% client-side. Processed locally in your browser using the Web Crypto API. Nothing is sent to any server.

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 SizeMax PlaintextSecurity LevelRecommended
RSA-2048190 bytes112-bitMinimum acceptable
RSA-3072318 bytes128-bitRecommended for most use
RSA-4096446 bytes152-bitHigh-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