
This is an implementation of the RSA encryption algorithm in C.
RSA encryption is based on the difficulty of factoring large composite numbers into their prime factors
In the key generation phase, two large prime numbers, pp and qq, are selected and multiplied to produce n=p×qn=p×q. The algorithm then computes Euler's totient function ϕ(n)=(p−1)(q−1) and chooses an encryption exponent ee that is coprime with ϕ(n). A decryption exponent d is derived as the modular inverse of e modulo ϕ(n), such that e×d≡1 mod ϕ(n). The public key consists of (e,n), while the private key is (d,n).
For encryption, a sender converts their plaintext message into an integer m (smaller than n) and computes the ciphertext c as c≡memod n. The recipient decrypts the message by computing m≡cdmod n, recovering the original plaintext.