There are many programs for encrypting and decrypting files under a Linux-based system. In this guide we will talk about Mcrypt which is a simple tool for encrypting or decrypting files via the command line. It is a replacement for the old crypt (Unix).

To install Mcrypt on Ubuntu (11.10/11.04/10.10), run this command from the terminal:

sudo apt-get install mcrypt

To encrypt a file with Mcrypt, open the terminal and run this command:

mcrypt file.txt

Replace "file.txt" with your own file name followed by its extension. The encrypted file will be created in the current folder having the ".nc" format and chmoded to 0600. If you want to delete the original file automatically after the encrypted file is created, then insert the -u parameter. Your command will be like this:

mcrypt -u file.txt

To decrypt the password protected file, use now this command:

mcrypt -d file.txt.nc

To delete the encrypted file after decryption, use this command:

mcrypt -u -d file.txt.nc

That's it!

Post a Comment