We sometimes need to hide our confidential data from other users. For that purpose we use encryption algorithms to encrypt our data. There are very many encryption algorithms but I am describing the Rivest, Shamir, Adleman (RSA) Algorithm.

About RSA

RSA is an encryption algorithm.Developed in: 1977.Developed by: Ron Rivest,Adi Shamir, and Leonard Adleman.The RSA algorithm is the most commonly used public key encryption algorithm.

Public Key Encryption

It is also known as asymmetric cryptography.

Two keys are used: Public Key and Private Key.

Public Key: For encryption.

Private Key: For decryption, also known as a secret key.

The preceding diagram show how public key encryption works,

In the diagram 2 users are shown:

First: The Sender (who is sending something by the recipient's Public Key)

Second: The Receiver (who is receiving something from the sender using the private key)

So in a public key cryptosystem, the sender encrypts the data using the public key of the receiver and uses an encryption algorithm that is also decided by the receiver and the receiver sends only the encryption algorithm and public key.

But by using the public key, data can only be encrypted but not decrypted, and the data is only decrypted by the private key that only the receiver has. So no one can hack our data.

In simple terms:

Public Key: Shared with the public that wants to send us data.Private Key: Kept secret so that when someone sends us data encrypted by our Public Key, we can decrypt the data using the Private Key.

HOW RSA WORKS

Both users (sender and receiver) generates a public and private key.

The following is the procedure for generating a public and private key (see flowchart).

Generation of Public and Private key in RSA

The flowcharts above shows how to generate a public and private key using RSA.

After getting the public and private key the main thing is how to encrypt and decrypt using RSA.

Encryption and Decryption in RSA

Example of RSA: Here is an example of RSA encryption and decryption with generation of the public and private key.