13

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

jww
  • 97,681
  • 90
  • 411
  • 885
JMK
  • 27,273
  • 52
  • 163
  • 280

1 Answers1

12

I think you want

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

See more at devco.

Roger Lindsjö
  • 11,330
  • 1
  • 42
  • 53