Encrypt and Decrypt files with ccrypt

In GNU/Linux, there are decent amount of tools with graphical interfaces that make file encrypting a breeze. However, there are also command-line based ones (few!) that let you easily encrypt/decrypt your data as well. Other than not having the ability to use the mouse (plus if you’re not a touch typist), most people don’t like command-line tools because they make you type a bit.

ccrypt is a utility for encrypting and decrypting files. It is based on the Advanced Encryption Standard, which is the U.S. government’s chosen candidate for the Advanced Encryption Standard . This cipher is believed to provide very strong security.
To install it run the following command:
  • $ sudo apt-get install ccrypt

To Encrypt the file run following command:

  • $ ccrypt myfile.mp3

You will be prompted to submit desired password to encrypt file which will be required to decrypt the file.

To Decrypt run following command:
  • $ ccrypt -d myfile.mp3

Using a “key-file”
A key-file is sort of a long password that’s saved in plain text which is used for additional security. So let’s assume that I wanted to encrypted the above mentioned mp3 file using a key-file instead of a password. Then I’d use something like the below command (assuming the key-file’s name is “mykey” and both the key-file and the mp3 files are in my “Home” folder).

  • $ ccrypt -K mykey myfile.mp3

ccrypt-usage1

Now you can see the orginal file will be deleted and the encrypted with will be with .cpt extension.
ccrypt-usage2

When you want to decrypt the file just use the default decrypt command, and when asked, type the key-file with its path.

  • $ ccrypt -d myfile.mp3.cpt

ccrypt-usage3

And now see, your file is back.
ccrypt-usage4

Changing passwords or the key-file
If you wanted to change the passwords or the key-file with ease (rather than decrypting and then re-encrypting it using a new password/key-file), then you can use the “-x” attribute.

For instance, if I wanted to change the password/key-file of the above mentioned mp3 file without decrypting it, then I’d use a command like the below one.

  • $ ccrypt -x myfile.mp3.cpt

When asked, first enter the old password and then the new one twice after that. That’s it!!!

Leave a Reply