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