UNIX File Encryption howto
Q. I’m using UNIX (FreeBSD) at work. I need to encrypt a file. What command I need to type?
A. You need to use crypt command which provides very simple file encryption. It works under UNIX, BSD, Linux and possible all other UNIX like oses.
Itis a very simple encryption program, working on a secret-key basis. It operates as a filter, i.e., it encrypts or decrypts a stream of data from standard input, and writes the result to standard output. Since its operation is fully symmetrical, feeding the encrypted data stream again through the engine (using the same secret key) will decrypt it.
Task: Encrypt the original file called my.txt
Type the command as follows:
$ cat my.txt | crypt > my.cpy
Output:
Enter key:
This will create an encrypted form of my.txt file, and store it in the file my.cpy.
Task: Ensure that the file is encrypted
Type the following command:
$ cat my.cpy
Task: Decrypt the file called my.txt
Type the command as follows:
$ cat my.cpy | crypt > my.file.txt
Under FreeBSD you can use enigma (same command with different name - the crypt utility, also known as enigma), to displays the previously created file on the terminal:
$ enigma PASSWORD < my.cpy
Also note that many new UNIX oses comes with mcrypt command. It is intended to be a replacement of the old unix crypt under the GNU General Public License.
Subscribe to our free e-mail newsletter or RSS feed to get all updates.
You can Email this page to a friend.
Related Other Helpful FAQs:
- OpenBSD Install Ports Collection
- OpenBSD Change Hostname
- Show all installed packages or software in Linux, FreeBSD, OpenBSD
- FreeBSD Install BASH Shell
- OpenBSD set up default boot time by modifying boot.conf file
Discussion on This FAQ
Leave a Reply
We encourage your comments, and suggestions. But please stay on topic, be polite, and avoid spam. Thank you very much for stopping by our site!
Tags: crypt_command, decrypt, encrypt, encrypted_data, encryption_program, enigma_command, file_encryption, secret_key, simple_encryption, unix_crypt




April 17th, 2007 at 1:25 pm
Note that the crypt command is notoriously weak. Use ccrypt and its associated commands instead. It uses AES encryption and is far stronger.
July 6th, 2008 at 6:09 am
I would prefer using gnupg which is available from FreeBSd ports.