Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Encrypt and decrypt a string of text with RSA and DES3 key

I am using the Linux command line, I have created a Private Key using the following command:

openssl genrsa -des3 -out private.pem 2048

I have extracted the public key from the private key like so:

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

I want to use the public key to encrypt a string of text, lets say "foo bar", and then decrypt this string again.

How do I go about this?

Thanks

like image 228
JMK Avatar asked Dec 21 '11 12:12

JMK


1 Answers

I think you want

openssl rsautl -encrypt -inkey public.pem -pubin -in unencrypted_file.txt -out encrypted_file.ssl

See more at devco.

like image 72
Roger Lindsjö Avatar answered Sep 22 '22 12:09

Roger Lindsjö