Skip to content

Instantly share code, notes, and snippets.

@zommuter
Forked from IcyApril/Hash Anonymity
Last active March 12, 2018 21:45
Show Gist options
  • Save zommuter/295fa281bbff7ad3a10a96cade9629db to your computer and use it in GitHub Desktop.
Save zommuter/295fa281bbff7ad3a10a96cade9629db to your computer and use it in GitHub Desktop.
#!/bin/bash
echo -n Password:
read -s password
echo
hash="$(echo -n $password | openssl sha1 -hex -r | cut -d" " -f1)"
upperCase="$(echo $hash | tr '[a-z]' '[A-Z]')"
prefix="${upperCase:0:5}"
response=$(curl -s https://api.pwnedpasswords.com/range/$prefix)
while read -r line; do
lineOriginal="$prefix$line"
if [ "${lineOriginal:0:40}" == "$upperCase" ]; then
echo "Password breached."
exit 1
fi
done <<< "$response"
echo "Password not found in breached database."
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment