pasta_scripts

some useful scripts
git clone https://git.pastanoggin.com/pasta_scripts.git
Log | Files | Refs | README | LICENSE

entropy (342B)


      1 #!/bin/sh
      2 # entropy: calculates the entropy of a password given the length and number of
      3 # possiblities
      4 
      5 num=0
      6 [ "$1" = '-n' ] && { num=1; shift; }
      7 [ "$#" -ne 2 ] && { echo "usage: ${0##*/} [-n] possibilites length " 1>&2; exit 1; }
      8 echo "l($1^$2)/l(2)" | bc -l | xargs printf "%.2f"
      9 [ "$num" -eq 0 ] && printf " bits of entropy"
     10 printf "\n"