Skip to content

Instantly share code, notes, and snippets.

@CognitiveDisson
Last active May 5, 2024 01:44
Show Gist options
  • Save CognitiveDisson/b7f773416c37b86248b7f498adf36bee to your computer and use it in GitHub Desktop.
Save CognitiveDisson/b7f773416c37b86248b7f498adf36bee to your computer and use it in GitHub Desktop.
One line to check pwned password
# Execute fc -p for the zsh shell if you want to remove it from the history.
# In this method, you don't pass the actual password value.
# Instead, you only send the first five characters of its SHA1 hash
# and then grep for the second part of the checksum locally within the response.
echo -n '<your_password>' | \
openssl dgst -sha1 -hex | \
awk '{print $2}' | \
tr a-z A-Z | \
xargs -I % sh -c 'curl -s "https://api.pwnedpasswords.com/range/$(echo % | cut -c -5)" | grep "$(echo % | cut -c 6-)"' | \
cut -d ":" -f2 | \
awk '{print "pwned: " $0}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment