Once in a while a person might like to encrypt a file for security purposes. In Linux it is real easy to create good encryption using openssl with the Triple-DES Cipher.:
openssl des3 -salt -in unencrypted-data.file \ -out encrypted-data.file.des3
After entering this command, openssl will ask for you to enter the password twice. And decryption is likewise:
openssl des3 -d -salt -in encrypted-data.file.des3 \ -out unencrypted-data.file
Remembering this command though is the tricky bit so I decided to create a couple bash scripts that made the process thoughtless. I named the bash scripts “crypten” and “cryptde“.
#!/bin/bash # crypten - a script to encrypt files using openssl FNAME=$1 if [[ -z "$FNAME" ]]; then echo "crypten <name of file>" echo " - crypten is a script to encrypt files using des3" exit; fi openssl des3 -salt -in "$FNAME" -out "$FNAME.des3"
The filename ends with .des3 to be easy to recognize.
#!/bin/bash
# cryptde - a script to decrypt files using openssl
FNAME=$1
if [[ -z "$FNAME" ]]; then
echo "cryptde <name of file>"
echo " - cryptde is a script to decrypt des3 encrypted files"
exit;
fi
openssl des3 -d -salt -in "$FNAME" -out "${FNAME%.[^.]*}"
I like to put my bash scripts in a ~/.bin folder. Don’t forget to make both files executable:
chmod +x crypten cryptde
This shouldhelp make encrypting/decrypting files easier.




Brian said
Never knew you could do that. That’s pretty cool. I wonder if I can teach people at work to do it.
felipe1982 said
First off, you need to make a nice theme for your wordpress. It is nearly IMPOSSIBLE to find posts on your site. I had to use google to search your site. I could not find an “archives” with alist of your posts. Secondly, your front page is TOO BIG. You should incorporate the “more . . .” feature, which trims your home-page posts to make them shorter. It will fill your home-page with more, but shorter, posts, which makes SEO better, and easier to skim the home-page for interesting (relevant) posts. The user can then click the MORE … link to read more on that particular post.
Excellent content on this site.
Now onto business
in bash do;
gpg -c your_file.txt
It asks for passphrase. This is 3-DES (default, but can be changed, read “man gpg”). IMO, gpg easier to learn than openssl, plus can do public-key encryption (i do not know if openssl is capable of that)