# RSA Algorithm

• The RSA algorithm, developed by Rivest, Shamir, and Adleman in 1978, is an asymmetric cryptography algorithm for encrypting and decrypting messages.
• Asymmetric means that the sender and receiver use two different keys for encryption and decryption: a private key and a public key.
• The public key is shared openly and is thus known to everyone, whereas the private key is kept secret and is not shared.
• The sender encrypts the data to be sent with the receiver’s public key and the receiver decrypts the encrypted message using its private key.

Steps in RSA algorithm

1. Generating the keys:

• Select two different large random prime numbers, p and q.
• Calculate n=p*q where n is the modulus for the public key and the private keys.
• Calculate the totient function; ϕ(n)=(x−1)(y−1).
• Select an integer e such that 1<e<ɸ(n) and e is co-prime to ɸ(n),gcd(e,ɸ(n))=1.
• Calculate d such that e.d=1 mod ϕ(n).
•  Public key is  given as <e,n> and private key as <d,n>.

2. Encryption:

The ciphertext C obtained from plain text P using the public key< e,n> is as follows:

C = Pe mod n

3. Decryption:

The Plaintext P obtained from CipherText C using the private key <d,n> is as follows:

P = Cmod n.