Skip to content

Instantly share code, notes, and snippets.

@antonlukin
Last active July 31, 2020 11:05
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save antonlukin/bbcf1ee651ec0a8c3d89aac89301189d to your computer and use it in GitHub Desktop.
Check if your password compromised using pwnedpasswords.com API
#!/usr/bin/env bash
set -e
#set -x
# ask user for password
read -p "Input password for check: " -t 30 passwd
if [ -n "$passwd" ]; then
hash=$(echo -n "$passwd" | sha1sum | awk '{print $1}')
partial_hash=${hash:0:5}
last_hash=${hash:5}
result=$(curl -q https://api.pwnedpasswords.com/range/${partial_hash} 2>/dev/null | tr [A-Z] [a-z] | grep "$last_hash")
if [ -n "$result" ]; then
echo "pwned: $result"
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment