Encrypting files with OpenSSL

The OpenSSL Project is an Open Source implementation of the Secure Sockets Layer and Transport Layer Security protocols as well as a cryptography library. In this tip I will show you how to encrypt an individual file using the openssl tool.

Probably GPG is a better choice for simple file encryption, but in some ocassions (i.e. encrypt without building keys or certificates) OpenSSL could be very useful. It’s very simple:

openssl enc -aes-256-cbc -salt -in SuperSecretFile.txt -out SuperSecretFile.txt.enc

And your are done! Now to decrypt the file:

openssl enc -d -aes-256-cbc -in SuperSecretFile.txt.enc -out SuperSecretFile.txt

A note from the man pages.

use a salt in the key derivation routines. This option should *ALWAYS* be used unless compatibility with previous versions of OpenSSL or SSLeay is required. This option is only present on OpenSSL versions 0.9.5 or above.

Tekið af: http://www.karkomaonline.com/index.php/2005/08/encrypting-files-with-openssl/

Tags: , , , , , ,

Leave a Reply

You must be logged in to post a comment.