Home Cryptoghraphy Asymmetric What is RSA Algorithm How to Encrypt and Decrypt Plain Text

What is RSA Algorithm How to Encrypt and Decrypt Plain Text

411
0
RSA algorithm
RSA algorithm

What Is An RSA Algorithm How to Encrypt and Decrypt Plain Text?

RSA is a public-key cryptosystem because in RSA two keys are used: public and private. The public is given to everyone and the private key is given only to those who have the authority to decrypt encrypted text.  RSA algorithm is used for secure information transmission. RSA algorithm was created by 3 cryptographers named “Ronald Rivest”, “Adi Shamir” and “Leonard Adleman”.

ethical hacking institute

The Algorithm Of RSA is an asymmetric cryptography algorithm. In RSA two keys are created; they are public and private. The public key is used for encrypting the data and the private key is used for decrypting the data. RSA is an algorithm used for modern computers to encrypt and decrypt messages. 

How data encryption and decrypt in RSA:

Encryption: In cryptography, encryption is the way toward encoding data. This process changes over the first portrayal of the data, known as plaintext, into an elective structure known as ciphertext. only an authorized person can change a ciphertext back to plaintext.

The formula of RSA Encryption:

C: ciphertext
P: plain text
n: p*q (p and q is two prime numbers)
e: Public key (e is co-prime to ϕ(n) and 1<e<ϕ(n))

C=P^​e mod n

Decryption: Decryption is processed to get an original form of ciphertext. It is for the most part an opposite process of encryption. It deciphers the scrambled data with the goal that an authorized user can just unscramble the information since decoding requires a mysterious key or secret word.

The formula of RSA Decryption:

C: ciphertext
P: plain text
n: p*q (p and q is two prime numbers)
d: private key (d=1 mod ϕ(n))

P=C^d mod n

Encryption and Decrypt in RSA with OpenSSL:

Create Private key with OpenSSL

OpenSSL genrsa -out private-key.pem 2048 

rsa private key
Create Private key with OpenSSL

Display private key

Display private key
Display private key

Create Public key with OpenSSL

OpenSSL RSA -pubout -in private-key.pem -out public-key.pem

creation of public key
Create Public key with OpenSSL

Display public key

Display public key
Display public key

 

Dump of Private key:

OpenSSL rsa -text -in private-key.pem

 

Dump of Private key
Dump of Private key with OpenSSL

Create a txt file and put the text which you want to encrypt:

Plain text
Create a txt file and put the text which you want to encrypt

Encrypt the text in RSA ciphertext with OpenSSL:

OpenSSL rsautl -encrypt -in text.txt -pubin -inkey public-key.pem -out text_encrypt.txt

encrypt plain text to cipher text
Encrypt the text in RSA ciphertext with OpenSSL

Display ciphertext:

ciphertext of RSA
Display ciphertext of RSA

Decrypt the ciphertext in RSA text with OpenSSL:

openssl rsautl -decrypt -in text_encrypt.txt  -inkey private-key.pem -out text_decrypt.txt

Decryption of rsa with private key
Decrypt the ciphertext in RSA text with OpenSSL

Display decrypted text:

orignal text of RSA cipher text
Display decrypted text from RSA ciphertext

 

You May Also Like To Read 

How to protect yourself from hackers 2021

What is LockBit Ransomware | Automates Encryption of Windows Domains

 

 

 

Previous articleWindows 11 Latest Update
Next articlePickle Rick TryHackMe Walkthrough

LEAVE A REPLY

Please enter your comment!
Please enter your name here