Skip to content

Instantly share code, notes, and snippets.

@sbuller
Created January 24, 2019 18:10
Show Gist options
  • Save sbuller/7b0a982473f77c6acdc26464ad5d6fe0 to your computer and use it in GitHub Desktop.
Save sbuller/7b0a982473f77c6acdc26464ad5d6fe0 to your computer and use it in GitHub Desktop.
Securely check passwords against https://haveibeenpwned.com/ DB.
#!/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