/RSA-Encryption

RSA Encryption in C++

Primary LanguageC++

RSA-Encryption

Example

RSA Encryption in C++

  1. The program first calculates two random prime numbers p and q
  2. n is calculated as n = p * q
  3. phi is as calculated as phi = (p - 1) * (q - 1)
  4. modular multiplicative inverse d is calculated as e * d % phi = 1
  5. The message is then encrypted as C(M) = M^e % n
  6. 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.