WebTool

Crypto & Security · Ch. 4

RSA for Beginners: Which Key Encrypts and Which Key Signs?

WebTool Team · Published 2026-09-08 · RSA / Asymmetric Encryption / Digital Signatures / Security

RSA uses a mathematically linked key pair: the public key is shared, the private key is kept secret. What the public key encrypts, only the private key can decrypt (confidentiality); what the private key signs, anyone can verify with the public key (identity and non-repudiation). The phrase "encrypt with the private key, decrypt with the public key" is inaccurate — that's called signing. This site offers an online RSA tool; key generation and all computation happen locally in your browser.

Don't mix up the two paths

Goal Operation Who can do it What it proves
Confidential transfer Public-key encrypt, private-key decrypt Anyone can encrypt Only the private-key holder can read it
Identity / signing Private-key sign, public-key verify Only the private-key holder It genuinely came from the key holder

Signing actually applies the private-key operation to the message's hash, not the full text. So JWT's RS256 is essentially SHA-256 hashing + RSA private-key signing.

Why real systems use hybrid encryption

RSA has two hard limits: it's slow (orders of magnitude slower than AES), and a single operation can encrypt less data than the key length (a 2048-bit key with OAEP padding encrypts only about 190 bytes). So real systems (HTTPS, PGP) all do this:

  1. Generate a random AES symmetric key;
  2. Encrypt the message body with AES (fast, no length limit);
  3. Encrypt that AES key with the RSA public key (short enough for one operation);
  4. The recipient uses their private key to recover the AES key, then decrypts the body.

Engineering choices

  • Key length: at least 2048 bits for new systems; 1024-bit is no longer recommended.
  • Padding: use OAEP for encryption and PSS for signatures; textbook "raw RSA" and the older PKCS#1 v1.5 encryption padding both have known attacks.
  • When to use ECC: at equivalent security, ECC (e.g. P-256) has shorter keys and faster operations — worth preferring in new systems; RSA wins on compatibility and ecosystem.

Last updated: 2026-09-08