RSA Encryption in C++
- The program first calculates two random prime numbers p and q
- n is calculated as n = p * q
- phi is as calculated as phi = (p - 1) * (q - 1)
- modular multiplicative inverse d is calculated as e * d % phi = 1
- The message is then encrypted as C(M) = M^e % n
- The message can then be decrypted using M(C) = C^d % n
Note that only alphabets (lowercase or uppercase) and spaces can be used in a message to be encrypted/decrypted.
Other characters may give unexpected results.