Encrypt and decrypt a file with OpenSSL

I was recently looking for a way of encrypting files with a salted encryption algruthum, and found this can be done using OpenSSL. It’s really easy and much more secure that using a zip product.

You do this by using the following syntax:

openssl des3 -salt -in /path/FileToBeEncrypted -out /path/EncryptedFileName

eg

openssl enc -aes-256-cbc -md sha512 -pbkdf2 -salt -in ~/test.txt -out ~/test.txt.enc

The salt is equivlent to a password, you will need this to decrypt the file in the future.

To decrypt the file you need to add the -d switch]

eg

openssl enc -aes-256-cbc -md sha512 -pbkdf2 -d -salt -in ~/test.txt.enc -out ~/test.txt