In this config we will show you a number of examples how to use mcrypt
tool to easily encrypt files whether the file is large or small in size. We will also use Mcrypt to encrypt and compress files and directories on the fly which can be usefully for a number of backup and scripting purposes.
Mcrypt installation
UBUNTU/DEBIAN # apt-get install mcrypt REDHAT/FEDORA/CENTOS # yum install mcrypt
Creating a testing sandbox
Let’s first create a directory with some files we can work with:
$ mkdir dir1 $ cd dir1/ $ echo "My File to Encrypt" > file1 $ cat file1 My File to Encrypt $ fallocate -l 500MB file2 $ md5sum file* bccd44aaa84c7c9d04a268f670ae92c5 file1 4034379ecc54213fc9a51785a9d0e8e2 file2