This program implements the RSA encryption scheme in C++ and allows for encryptng and decrypting integers.
- Let e = 65537
- Find two large unique prime numbers p and q
- Calculate n = pq
- Calculate ϕ(n) = (p - 1)(q - 1)
- Make sure that 1 < e < ϕ(n) and e is coprime with ϕ(n)
- Solve the congruence ed === (mod ϕ(n))
- Your public key is (e, n) and your private key is (d, n)
- The public key is used for encrypting a message M
- To do so, we perform the operation C === M^e (mod n)
- C is your ciphertext (encrypted number)
- The private key is used for decrypted the ciphertext C to retrieve the original message M
- To retrieve M, we calculate M === C^d (mod ϕ(n))
- M is your original message