RSA Encrypt & Decrypt
Encrypt with RSA public key, decrypt with private key — OAEP padding
How to Use the RSA Encrypt & Decrypt
- Encrypt: Paste an RSA public key (PEM) and plaintext, then click Encrypt.
- Decrypt: Paste an RSA private key (PEM) and the Base64 ciphertext, then click Decrypt.
RSA encryption uses the Web Crypto API (RSA-OAEP with SHA-256). Maximum message size depends on key size (e.g., ~190 bytes for 2048-bit keys). Generate key pairs using the RSA Key Generator tool.
What is RSA Encryption & Decryption?
RSA (Rivest-Shamir-Adleman) is the foundation of asymmetric public-key cryptography. This tool enables developers to encrypt sensitive messages using an RSA public key and decrypt the resulting ciphertext using the matching RSA private key. Supporting standard PKCS#1 and OAEP padding with keys up to 4096 bits, it illustrates how asymmetric keypairs protect data in transit.
Common Uses
- Secure key exchange mechanisms for establishing symmetric session keys (hybrid encryption)
- Encrypting sensitive API credentials or license tokens for offline client decryption
- Testing asymmetric encryption workflows during PKI and TLS application development
- Educational demonstrations of asymmetric public/private key mathematics
Frequently Asked Questions
Why can't RSA directly encrypt very large files?
RSA mathematical operations are computationally intensive, and an RSA key can only encrypt data shorter than its key size minus padding (e.g. 2048-bit RSA can only encrypt up to 214 bytes with OAEP). In practice, systems use hybrid encryption: encrypting the file with fast AES and encrypting the AES key with RSA.
What is the difference between RSA PKCS#1 v1.5 and OAEP padding?
OAEP (Optimal Asymmetric Encryption Padding) incorporates cryptographic hashing and randomization to prevent padding oracle attacks. OAEP is the modern recommended standard for RSA encryption.
Is it safe to paste private keys here?
Aya Corporation runs 100% inside your local browser sandbox using Web Crypto. Keys are never transmitted over the internet or logged on any server. However, for active production keys, always adhere to strict air-gapped security protocols.
Notes from this implementation
Block size is the limit you will hit first
RSA does not encrypt a document. It encrypts a short block that has to be smaller than the modulus, minus padding. With a 2048-bit key and OAEP or PKCS#1 v1.5, you get a couple of hundred bytes. Pasting a paragraph will fail or, in a sloppy implementation, silently truncate. The usual pattern is: generate a random AES key, encrypt the file with AES, and encrypt that AES key with the RSA public key. This page is the second step, and a way to see the first step fail when the message is too long.
Use the public key to encrypt and the private key to decrypt. Reversing them is a different operation (a signature). A value you “decrypted” with the public key is not confidential; anyone with the public key can do that.
Padding
PKCS#1 v1.5 padding has a long history of padding-oracle bugs. If the form offers OAEP, use it for new experiments. Do not paste a production private key into a browser on a machine you do not control. The PEM is in the page after you paste it.