第一个:
#!/bin/ksh
#乐山市沙湾区邮政局 宋 涛
#按位取反加密数字的shell V050820
clear
echo "\n 按位取反加密数字的shell \n"
while :
do
echo -n "\n\n\n 请输入原密码: "
read num
test $num || { echo exit 0 }
numn=${#num}
passwd=$((~num))
echo "\n 加密密码为: "$passwd
unpasswd=`echo $((~passwd))`
unpasswdn=${#unpasswd}
test $numn -gt $unpasswdn && unpasswd=`printf "%0$((numn-unpasswdn))d"$unpasswd`
echo "\n 源密码为: "$unpasswd
done
第二个:
#!/bin/ksh
#乐山市沙湾区邮政局 宋 涛
#按位取反加密数字的shell V050820
#增加输入必须为6位数字的判断
trap "tput sgr0 echo " 0 1 2 3 9 15
tput bold
clear
echo "\n 按位取反加密数字的shell \n"
while :
do
echo -n "\n\n\n 请输入原密码: "
read num
test $num || { echo exit 0 }
[[ $num == *([0-9]) && ${#num} -eq 6 ]] || { echo "\n\n 请输入6位数字 \n" read clear continue }
numn=${#num}
passwd=$((~num))
echo "\n 加密密码为: "$passwd
unpasswd=`echo $((~passwd))`
unpasswdn=${#unpasswd}
test $numn -gt $unpasswdn && unpasswd=`printf "%0$((numn-unpasswdn))d"$unpasswd`
echo "\n 源密码为: "$unpasswd
done
第三个:
#!/bin/ksh
#乐山市沙湾区邮政局 宋 涛
#按位取反加密数字的shell V050820
#增加输入必须为6位数字的判断
#增加先两两交*取反
trap "tput sgr0 echo " 0 1 2 3 9 15
tput bold
clear
echo "\n 按位取反加密数字的shell \n"
while :
do
echo -n "\n\n\n 请输入原密码: "
read num
test $num || { echo exit 0 }
[[ $num == *([0-9]) && ${#num} -eq 6 ]] || { echo "\n\n 请输入6位数字 \n" read clear continue }
num=`echo $num | sed 's/\(.\)\(.\)/\2\1/g'`
num=`echo 1$num`
passwd=$((~num))
echo "\n 加密密码为: "$passwd
unpasswd=`echo $((~passwd))`
unpasswd=`echo $unpasswd | cut -c2-| sed 's/\(.\)\(.\)/\2\1/g' `
echo "\n 源密码为: "$unpasswd
done
第四个:
#!/bin/ksh
#乐山市沙湾区邮政局 宋 涛
#按位异或加密数字的shell V050820
clear
echo "\n 按位异或加密数字的shell \n"
while :
do
echo -n "\n\n\n 请输入原密码: "
read num
test $num || { echo exit 0 }
num=`echo 8$num`
passwd=$((num^11111))
echo "\n 加密密码为: "$passwd
unpasswd=`echo $((passwd^11111))|cut -c2-`
echo "\n 源密码为: "$unpasswd
done
修正版:
#!/bin/ksh
#乐山市沙湾区邮政局 宋 涛
#按位取反加密数字的shell V050820
#增加输入必须为6位数字的判断
#增加先两两交*取反
#增加数字<->字母替换 V050829
trap "tput sgr0 echo " 0 1 2 3 9 15
tput bold
clear
echo "\n 按位取反加密数字的shell \n"
while :
do
echo -n "\n\n\n 请输入原密码: "
read num
test $num || { echo exit 0 }
[[ $num == *([0-9]) && ${#num} -eq 6 ]] || { echo "\n\n 请输入6位数字 \n" read clear continue }
num=`echo $num | sed 's/\(.\)\(.\)/\2\1/g'`
num=`echo 1$num`
passwd=$((~num))
passwd=`echo $passwd|sed 's/1/a/;s/2/b/;s/3/c/;s/4/d/;s/5/e/;s/6/f/;s/7/g/;s/8/h/;s/9/j/;s/0/i/'`
echo "\n 加密密码为: "$passwd
unpasswd=`echo $passwd|sed 's/a/1/;s/b/2/;s/c/3/;s/d/4/;s/e/5/;s/f/6/;s/g/7/;s/h/8/;s/j/9/;s/i/0/'`
unpasswd=`echo $((~unpasswd))`
unpasswd=`echo $unpasswd | cut -c2-| sed 's/\(.\)\(.\)/\2\1/g' `
echo "\n 源密码为: "$unpasswd
done
#!/bin/ksh
#乐山市沙湾区邮政局 宋 涛
#按位异或加密数字的shell V050820
#增加输入必须为6位数字的判断
#增加先两两交*取反
#增加数字<->字母替换 V050829
trap "tput sgr0 echo " 0 1 2 3 9 15
tput bold
clear
echo "\n 按位异或加密数字的shell \n"
while :
do
echo -n "\n\n\n 请输入原密码: "
read num
test $num || { echo exit 0 }
[[ $num == *([0-9]) && ${#num} -eq 6 ]] || { echo "\n\n 请输入6位数字 \n" read clear continue }
num=`echo 8$num`
passwd=`echo $((num^111111)) | sed 's/\(.\)\(.\)/\2\1/g'`
passwd=`echo $passwd|sed 's/1/a/;s/2/b/;s/3/c/;s/4/d/;s/5/e/;s/6/f/;s/7/g/;s/8/h/;s/9/j/;s/0/i/'`
echo "\n 加密密码为: "$passwd
unpasswd=`echo $passwd|sed 's/a/1/;s/b/2/;s/c/3/;s/d/4/;s/e/5/;s/f/6/;s/g/7/;s/h/8/;s/j/9/;s/i/0/'`
unpasswd=`echo $unpasswd | sed 's/\(.\)\(.\)/\2\1/g'`
unpasswd=`echo $((unpasswd^111111)) | cut -c2- `
echo "\n 源密码为: "$unpasswd
done
|
|
|