How To Generate Public Key And Private Key Encryption Decryption In Asymmetric Cryptography

In this tutorial we are going to learn something about the cryptography means the encryption and decryption of public key and private key in Asymmetric Cryptography In Redhat Enterprise Linux

Just Follow these simple steps and learn something new about the encryption and decryption of public and private key in Cryptography

Step-1 How to create a Private key

Here is the command to create the private key in Redhat Enterprise Linux

Firstly login with the root in Linux and then first create the folder

Here i am creating the folder first then i will create a private key

#mkdir redhat

#cd redhat

Screenshot (64)

After then now we create a private key
Here is the command

[root@localhost redhat]# openssl genrsa -out private.pem 1024
Generating RSAprivate key, 1024 bit long modulus
........................++++++
...................++++++
e is 65537 (0x10001)
[root@localhost redhat]#
Screenshot (66)

Step-2 Now Using Private key we are going to create Public Key.

[root@localhost redhat]# openssl rsa -in private.pem -out public.pem -outform PEM -pubout

000

step-3 Here now we have to create a text file

Here is a command to create a text file

[root@localhost redhat]# echo " hello how are you where do you live" > rj.txt

Screenshot (67)

Step-4 Now how to encrypt this rj text file using public key

Here is the command you can see how i encrypt this text file using this command

[root@localhost redhat]# openssl rsautl -encrypt -inkey public.pem -pubin -in rj.txt -out encrypt.bat

Screenshot (69)

Step-5 Now we are deleting this text file which text file name is rj
Here is the command to delete the text file

[root@localhost redhat]# rm -rf rj.txt
Screenshot (71).png

Step 6: Now we have to Decrypt this File using Private Key

[root@localhost redhat]# openssl rsautl -decrypt -inkey private.pem -in encrypt.bat -out linux.txt

Screenshot (72)
Now we decrypted this file now we have to check the content
Here is the command you can see how i am checking the content of linux.txt

[root@localhost redhat]# cat linux.txt
hello how are you where do you live
[root@localhost redhat]#

Screenshot (73)

This is All How To Generate Public Key And Private Key Encryption Decryption In Asymmetric Cryptography

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: