Skip to content

Instantly share code, notes, and snippets.

@adefelicibus
Forked from rvalieris/hibp.py
Created May 3, 2018 17:28
Show Gist options
  • Save adefelicibus/91c34895b627dbbe13d5708cc3dd6c56 to your computer and use it in GitHub Desktop.
Save adefelicibus/91c34895b627dbbe13d5708cc3dd6c56 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