RSA is an algorithm used by modern computers to encrypt and decrypt messages. Modern encryption is mostly based on this algorithm.
It is an asymmetric cryptographic algorithm.
Asymmetric means that there are two different keys. This is also called public key cryptography because one of the keys can be given to anyone. The other key must be kept private, Elliptic curve algorithm uses asymmetric cryptography also.
The algorithm is based on the fact that finding the factors of a large composite number is difficult: when the integers are prime numbers, the problem is called prime factorization. It is also a key pair (public and private key) generator.
- Choose two different large random prime numbers and
- Calculate (n is the modulus used later.
- Calculate the totient:
- Choose an integer such that and is coprime to
- compute such that
Source code link: GitHub repository