RSA encryption example

This an example of rsa encryption (Size is 2048)  using openssl tool. Output will be in base64 format, so that it can be shared easily.

Step 1: Generate the private key file

$ openssl genrsa -out private.pem 2048

Step 2: Extract the public key file

$ openssl rsa -in private.pem -out public.pem -outform PEM –pubout

Step 3 : Save your secret key in secret.txt

 Step 4: Encrypt the secret file

$ openssl rsautl -encrypt -inkey public.pem -pubin -in secret.txt –out secret.ssl

Step 5: Convert to base 64

$ openssl enc –base64 –in secret.ssl –out secret.ssl.enc


Leave a Reply

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

You are commenting using your 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