1. 程式人生 > >bash 實現複雜密碼生成

bash 實現複雜密碼生成

#只要輸入登陸的網站地址就能得出一個複雜的密碼

#懶人配備


echo "Please input you wanto login website:"
read website
echo
echo
password=`echo "$website" |sed 'y/[email protected]/@9506aqsob>/'`
length=${#password}


for i in `seq 0 $length`
   do

  a=${password:i:1}
   b=`echo {a..z} | grep -o "$a" `

    if [ -z $b ];then
       echo -n "$a"
       else
         c=`echo "$b" | tr [a-z] [A-Z]`
          echo -n $c
          t=$(( $length - $i  ))
          f=$(( $i + 1))
          d=${password:f:t}
          echo -n $d
          break
     fi

done

echo ""