Simple File Encryption Decryption In Linux


Simple File Encryption Decryption In Linux I was recently looking for a quick method of encrypting/decrypting my important files in Linux (but didn’t want to go as far as CryptFS). I chose to use OpenSSL, which has a vareity of uses and one of those includes encryption and decryption of files. It’s fairly easy to use and a passphrase is required for encrypting/decrypting a file.

A quick guide to encrypting a file:
openssl enc -des-cbc -in <filename.txt> -out <filename.enc>
And to decrypting a file:
openssl enc -des-cbc -d -in <filename.enc> -out <filename.txt>
It’s pretty straight forward: replace -des-cbc with the encryption type you prefer (check "man openssl" for a list) and filename.* with the file you want to encrypt, e.g. my-cv.doc and encrypt as mycv.enc or thomas.backup. "-in" is the file to encrypt/decrypt and "-out" is the target file. "-d" tells openssl to decrypt.

When excuting the encryption command, openssl will ask for a passphrase (twice) and then create an encrypted copy of the file in the current directory (unless you specify to output elsewhere). When decrypting the file, the passphrase is only asked for once and a new file will be created with the unencrypted data.

It’s important to not forget the passphrase, otherwise you could find yourself with a hard and long time trying to decrypt it…

Share and Enjoy:
  • Digg
  • del.icio.us
  • BlinkList
  • Furl
  • Netscape
  • Reddit
  • StumbleUpon
  • YahooMyWeb




Write a comment:

(Required, but won't be displayed)