RSA Encryption & Decryption
Encrypt a short message with an RSA public key (RSA-OAEP) and decrypt it with the private key.
Input
Public key
RSA encrypts small things
RSA-OAEP can only encrypt data shorter than the key modulus minus its padding — about 190 bytes with a 2048-bit key. This is not a limitation to work around; it is what RSA is for.
The standard pattern is hybrid encryption: generate a random AES key, encrypt the data with AES, encrypt only that key with RSA, and send both. Every TLS handshake is a variation on this.
The public key encrypts; only the matching private key decrypts. That asymmetry is the whole point — you can publish the encrypting half.
Frequently asked questions
Why does encrypting a long message fail?
It exceeds what the key can hold. Use the AES tool for the data and RSA only for the AES key.
Should I pick SHA-256 or SHA-1 for OAEP?
SHA-256. SHA-1 is offered only because some older systems hard-code it, and the two are not interchangeable — decryption fails if the sides disagree.