dotfiles

My personal shell configs and stuff
git clone git://git.alex.balgavy.eu/dotfiles.git
Log | Files | Refs | Submodules | README | LICENSE

pwnedpass (406B)


      1 #!/bin/sh
      2 printf "pass> "
      3 stty -echo
      4 read -r pass_str
      5 stty echo
      6 sha1=$(printf "%s" "$pass_str" | tr -d '\n' | shasum -a 1)
      7 prefix=$(printf "%s" "$sha1" | cut -c-5)
      8 suffix=$(printf "%s" "$sha1" | cut -c6-35)
      9 printf "Hash prefix: %s\n" "$prefix"
     10 printf "Hash suffix: %s\n" "$suffix"
     11 result=$(curl -sL https://api.pwnedpasswords.com/range/"$prefix" 2>/dev/null | grep -i "$suffix")
     12 echo "Count: ${result#*:}"