Blame


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