This is a project based on my SRP (specialised study project) from Danish high school. The code implementation can be fund under the folder python_code.
RSA encryption is developed by Ron Rivest, Adi Shamir and Len Adleman in 1977. It is based on the prime factorization problem. In order to encrypt and decrypt, two public keys🔑🔑 (
- Choose two prime numbers
$p$ and$q$ , the set$n=p\cdot q$ - Calculate
$\phi(n) = (p - 1)(q - 1)$ - Choose a whole number, so
$0 < e <\phi(n)$ and$\text{gcd}(e, \phi(n)) = 1$ - Calculate
$d$ so,$ed \equiv 1 (\text{mod } \phi(n))$
Now that the keys are fund, we can use them to encrypt. As follows
where
When decrypting we use
Why does this work? Let start by substituting
This can be written as
Since
The key
This only applies when
To break the RSA encryption we need to find the private key
We can use Fermat's method to find
To find
When a solution where