Skip to content

Instantly share code, notes, and snippets.

@bheisig
Created February 17, 2019 13:14
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bheisig/985edd149b5c0f3dd3a086620e8edeb3 to your computer and use it in GitHub Desktop.
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)
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