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

JMK picture JMK · Dec 21, 2011 · Viewed 10.4k times · Source

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

Answer

Roger Lindsjö picture Roger Lindsjö · Dec 21, 2011

I think you want

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

See more at devco.