Skip to content

Instantly share code, notes, and snippets.

@ayosec
Created December 17, 2012 21:43
Show Gist options
  • Save ayosec/4322566 to your computer and use it in GitHub Desktop.
Save ayosec/4322566 to your computer and use it in GitHub Desktop.
Encrypt/descrypt with OpenSSL and RSA

OpenSSL and RSA

You can encrpt files using a private/public keys.

First, create the keys:

openssl req -x509 -nodes -days 100000 -newkey rsa:2048 \
  -keyout private.pem -out public.pem -subj /

Encrypt the important.file with:

openssl smime -encrypt -aes256 -in important.file -binary \
  -outform DEM -out file.secure public.pem

And decrypt it with

openssl smime -decrypt -in file.secure -binary -inform DEM \
  -inkey private.pem -out important.file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment