Skip to content

Instantly share code, notes, and snippets.

@Serpens
Created May 29, 2018 15:09
Show Gist options
  • Save Serpens/463fff82cc78567cb901bdf809ae17fe to your computer and use it in GitHub Desktop.
Save Serpens/463fff82cc78567cb901bdf809ae17fe to your computer and use it in GitHub Desktop.
Check if a password, given as command line argument, is pwned
#!/bin/bash
PASSWORD=$1
HASH=$(echo -n $1 | sha1sum | cut -f1 -d' ' | tr '[:lower:]' '[:upper:]')
HASH_START=$(echo $HASH | cut -c1-5)
HASH_END=$(echo $HASH | cut -c6-40)
curl -s https://api.pwnedpasswords.com/range/$HASH_START | grep $HASH_END &>/dev/null && echo 'weak password' || echo 'strong password'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment