Created
February 17, 2019 13:14
-
-
Save bheisig/985edd149b5c0f3dd3a086620e8edeb3 to your computer and use it in GitHub Desktop.
Have I been pwned? One-liner bash script to check your passwords (requires BASH v4)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
read -s -p "Password: " p; echo; h="$(echo -n $p | sha1sum | cut -d' ' -f1)"; echo "SHA1: $h"; s="${h:0:5}"; u="https://api.pwnedpasswords.com/range/$s"; echo "HTTP GET $u"; r=$(curl -s "$u"); c=0; for l in $r; do t="$(echo "${s}${l%:*}" | tr 'A-Z' 'a-z')"; test "$t" == "$h" && c="$(echo ${l##*:} | tr -d "[:cntrl:]")"; done; echo "Your password has been pwned $c time(s)" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment