RSA Encryption
What You'll Learn
You'll learn how to encrypt a plaintext message using the public key in the RSA cryptosystem.
The Core Idea
Now that you have your RSA public key (e, n) set up, you're ready to encrypt messages. Encryption is the process of transforming a readable plaintext message into an unreadable ciphertext that only the holder of the private key can decrypt.
The encryption operation is surprisingly elegant:
To encrypt a plaintext message m, compute:
c ≡ m^e (mod n)
Here:
mis your plaintext message (represented as a number less thann)eis the public exponent (part of the public key)nis the modulus (the product of two primes, also public)cis the resulting ciphertext
How It Works
Think of encryption like locking a box with a special key. Anyone with your public key (e, n) can lock messages for you, but only you (with your private exponent d) can unlock them.
Example
Suppose your public key is (e=5, n=14) and you want to encrypt m=3:
c ≡ 3^5 (mod 14)
c ≡ 243 (mod 14)
c ≡ 5 (mod 14)
Your ciphertext is c = 5. Anyone with the public key can perform this calculation, but recovering m from c requires the private key—a problem that's computationally infeasible with large primes.
Key Takeaway: RSA encryption transforms plaintext m into ciphertext c using modular exponentiation: c ≡ m^e (mod n), where (e, n) is the public key available to anyone who wants to send you secure messages.