|
Cannot find the "crypt" command in Linux
by Jeff Hunter, Sr. Database Administrator
Contents
Overview
This version follows the syntax of the original "crypt", although I'm certain that the
algorithm is different. The encryption and the decryption are symmetric, meaning
that the same syntax is used for both (with the obvious exception of the
relevant filenames)
While attempting to port several applications written on the Solaris platform to Linux,
I needed to use the "crypt" program, to encode a text file (for those of you unfamiliar
with it, it encrypts the contents of a file using a password that you supply. A fairly
useful little utility when you want just a bit of added security on a publicly-readable
file.) Imagine my surprise when I found that Linux does not have one! Thanks to Ben
Okopnik for creating a small Perl utility that provides the functionality of the "crypt"
program.
Usage
# This encrypts the contents of "mysecret.txt" using "iAMw0tIam" as the
# password and saves the results to "mysecret.encrypted".
crypt iAMw0tIam < mysecret.txt > mysecret.encrypted
# This prints out the decrypted contents of "mysecret.encrypted" to the
# screen.
crypt iAMw0tIam < mysecret.encrypted
# This decrypts the contents of "mysecret.encrypted" and writes the results
# to "mysecret.decrypted".
crypt iAMw0tIam < mysecret.encrypted > mysecret.decrypted
Long passwords are preferable to short ones for better security;
"crypt" accepts them without a problem, provided that any password containing
spaces or other "weird characters" is quoted (preferably in single quotes).
crypt 'Praeterea, censeo Carthaginem esse delendam.' < file > file.enc