What is RSA Algorithm How to Encrypt and Decrypt Plain Text
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”.
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
Display private key
Create Public key with OpenSSL
OpenSSL RSA -pubout -in private-key.pem -out public-key.pem
Display public key
Dump of Private key:
OpenSSL rsa -text -in private-key.pem
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
Display ciphertext:
Decrypt the ciphertext in RSA text with OpenSSL:
openssl rsautl -decrypt -in text_encrypt.txt -inkey private-key.pem -out text_decrypt.txt
Display decrypted text:
You May Also Like To Read
How to protect yourself from hackers 2021
What is LockBit Ransomware | Automates Encryption of Windows Domains