How to decrypt / encrypt file in Linux
File encryption and decryption in Linux
Mcrypt command
Mcrypt is a simple crypting program, a replacement for the old unix crypt. When encrypting or decrypting a file, a new file is created with the extension .nc and mode 0600. The new file keeps the modification date of the original. The original file may be deleted by specifying the -u parameter.
Examples
Encrypt data.txt file:
$ mcrypt data.txt
Output:
Enter the passphrase (maximum of 512 characters)
Please use a combination of upper and lower case letters and numbers.
Enter passphrase:
Enter passphrase:
A new file is created with the extension .nc i.e. data.txt.nc:
$ ls data.txt.nc
$ cat data.txt.nc
Decrypt the data.txt.nc file:
$ mcrypt -d data.txt.nc
Output:
Enter passphrase:
File data.txt.nc was decrypted.
Verify that file was decrypted:
$ ls data.txt
$ cat data.txt
For mcrypt to be compatible with the Solaris des, the following parameters are needed:
$ mcrypt -a des –keymode pkdes –bare -noiv data.txt
Delete the input file if the whole process of encryption/decryption succeeds (pass -u option):
$ mcrypt -u data.txt
OR
$ mcrypt -u -d data.txt.nc
Category: Linux Administration
