Skip to content

Instantly share code, notes, and snippets.

@dwelch2344
Last active August 29, 2015 14:06
Show Gist options
  • Save dwelch2344/2f4d2f493e65432ccaea to your computer and use it in GitHub Desktop.
Save dwelch2344/2f4d2f493e65432ccaea to your computer and use it in GitHub Desktop.
OpenSSL RSA cert + private key encryption of files locally
# Generate our cert and key
openssl req -x509 -days 10000 -newkey rsa:2048 -keyout key.pem -out setup.crt -subj '/'
# Strip the password off the key
openssl rsa -in key.pem -out key.pem
# Encrypt our file
openssl smime -encrypt -aes256 -binary -outform PEM -in file.txt -out file.aes setup.crt
# Decrypt our file
openssl smime -decrypt -inform PEM -binary -in file.aes -inkey key.pem -out decrypted.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment