程序代码如下:
#!/bin/bash
#project deen.sh by vzomik
#description: encrypt & decrypt text file,
# it can auto check the file encrypted or not.
if [ -n $1 ]; then
filename=$1
else
echo "You have no input filename to process yet!"
exit 1
fi
function vz_decrypt
{
unset clear_text && unset cipher_text
cipher_text=`zcat $filename`
echo "$cipher_text" |base64 -d >$filename && cat $filename
echo -e "\n\t file $filename had been decrypted!"
exit 0
}
function vz_encrypt
{
unset clear_text && unset cipher_text
clear_text=`cat $filename`
echo "$clear_text" |base64 -i >$filename && gzip $filename
mv `echo $filename.gz` $filename && zcat $filename
echo -e "\n\t file $filename had been encrypted!"
exit 0
}
if [ -n "$(file $filename |grep 'text')" ]; then
vz_encrypt
elif [ -n "$(file $filename |grep 'gzip')" ]; then
vz_decrypt
else
echo -e "\n\t file $filename can not be authenticated,"
echo -e "\t so $filename will not encrypt or decrypt!\n"
exit 1
fi 阅读全文
类别: 默认分类 查看评论