Skip to content

Instantly share code, notes, and snippets.

@rvalieris
Created May 3, 2018 17:27
Show Gist options
  • Save rvalieris/f6a2ca6786c19e7786a94e5878f68416 to your computer and use it in GitHub Desktop.
Save rvalieris/f6a2ca6786c19e7786a94e5878f68416 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python3
import requests
import hashlib
import getpass
password = getpass.getpass()
hash = hashlib.sha1(password.encode("utf8")).hexdigest().upper()
head, rest = hash[:5], hash[5:]
r = requests.get("https://api.pwnedpasswords.com/range/%s" % head)
if rest in r.content.decode("utf8"):
print("Password breached.")
else:
print("You're good... For now.")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment