Power with modular exponentiation

Iterative Function to calculate (b^n) % m in O(log n)



Greatest Common Divisor

Using the Euclidean approach

Two numbers are coprime if GCD is 1



Fermat's Little Theorem

if p is a prime number, and a is an integer, then

a^p = a % p

a^(p-1) = 1 % p



RSA

Choose two prime numbers p and q











Checking d: 0





Public key is (e, n) =>

Private key is (d, n) =>