Command Line encrypt & decrypt of files – OpenSSL

Ever had the need to quickly encrypt a file?
We have previously shown you a tool called Cryptor for simple Encryption/Decryption on OSX.

In this post we will show you how to use OpenSSL.

OpenSSL - Command Line usage

With OpenSSL you can perform quick and easy encrypt/decrypt of files from the Command Line.
As long as OpenSSL is installed on your system, you can use the same examples as below on any OS (Windows,Linux,OSX).

In these examples i have used the DES3 encryption algortithm.

The OpenSSL syntax for encrypting a file is simple:

openssl [encryption type] -in [file to encrypt]

Encrypting a file

The example below takes a .txt file as input and outputs a different file. This is done by just changing the name, or in this example adding _enc to the filename. After encrypting the file, your original file will still be around, so you should take care of that in a secure manner.(secure delete)

openssl des3 -in myfile.txt -out myfile_enc.txt

You will be prompted for a password when entering this command. Do NOT loose that password.

Decrypting a file

openssl des3 -d -in myfile_enc.txt -out myfile_dec.txt

You will be prompted for the same password and your file is decrypted.

Thats it!

Try opening your encrypted file to see that the text has been garbled and is unreadable.

One thought on “Command Line encrypt & decrypt of files – OpenSSL

Leave a Reply

Your email address will not be published. Required fields are marked *