-
-
Save sbuller/7b0a982473f77c6acdc26464ad5d6fe0 to your computer and use it in GitHub Desktop.
Securely check passwords against https://haveibeenpwned.com/ DB.
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 | |
while read -sp Password: password; do | |
echo | |
sha1=$(printf "$password" | sha1sum -) | |
range=$(echo $sha1 | cut -b1-5) | |
rest=$(echo $sha1 | cut -b6-40 | tr 'a-f' 'A-F') | |
part2=$(echo $rest | cut -b1-8) | |
result=$(curl -s "https://api.pwnedpasswords.com/range/$range" | grep ^$part2) | |
echo $rest | |
echo $result | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment