EN

RSA Encrypt

RSA online encryption with 2048/3072/4096-bit key generation

FAQ

What are the public and private keys for?

Public key encrypts, private key decrypts, which is the mode this tool uses. Signing with the private key and verifying with the public key is a different use case and not covered here.

2048-bit or 4096-bit?

2048 is still secure and faster, the common choice. 4096 resists future compute better but is noticeably slower with longer ciphertext.

Why is long text split into chunks?

The amount of data RSA can encrypt in one operation is bounded by the key size, so longer input must be chunked and concatenated, producing a proportionally longer ciphertext.

About this tool

This tool does exactly one thing: RSA-OAEP with SHA-256 - encrypt with the public key, decrypt with the private key. Signing and verification are a different mode and are not offered here.

Keys are generated locally in the browser at 2048, 3072 or 4096 bits. Bigger is slower: 3072-bit generation typically takes a few hundred milliseconds up to a couple of seconds on a laptop, which is expected.

Only two PEM layouts are accepted: SPKI for public keys (-----BEGIN PUBLIC KEY-----) and PKCS#8 for private keys (-----BEGIN PRIVATE KEY-----). The older PKCS#1 headers (BEGIN RSA PUBLIC KEY, BEGIN RSA PRIVATE KEY) are rejected - convert them first with openssl rsa -in old.pem -pubout for the public key and openssl pkcs8 -topk8 -nocrypt -in old.pem for the private key.

Chunk size comes from the key: one block holds at most key bytes minus 66 (OAEP with SHA-256 uses two 32-byte digests plus 2 bytes of overhead). That is 190 bytes at 2048 bits, 318 at 3072 and 446 at 4096; longer input is split at that size and the blocks concatenated. The chunk size follows the imported key rather than the bit size selected above - pasting a 2048-bit public key while 3072 is selected would otherwise fail every time.

The result is each ciphertext block padded to the key length, concatenated, then Base64-encoded as a whole. It is neither a PKCS#7 envelope nor PEM, so another tool must apply the same chunking rule to read it.

RSA is a poor fit for bulk data: chunking costs overhead and it protects confidentiality only, with no integrity guarantee. Production systems use hybrid encryption - RSA wraps a temporary AES key and the payload goes through AES-GCM.