-
-
Save shoeper/cd84e312cda3f53af52944813e1424ba to your computer and use it in GitHub Desktop.
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
#!/bin/bash | |
echo -n Password: | |
read -s password | |
echo | |
hash="$(echo -n $password | openssl sha1)" | |
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