Skip to content

Instantly share code, notes, and snippets.

@ShakataGaNai
Created February 22, 2018 00:17
Show Gist options
  • Save ShakataGaNai/cb786a2c64abc83d4dbe0dbf6b60a5e3 to your computer and use it in GitHub Desktop.
Save ShakataGaNai/cb786a2c64abc83d4dbe0dbf6b60a5e3 to your computer and use it in GitHub Desktop.
#!/usr/bin/python
from getpass import getpass
import hashlib
import requests
import sys
import re
passd = getpass('Gimme your password: ')
hash = hashlib.sha1(passd).hexdigest().upper()
res = requests.get('https://api.pwnedpasswords.com/range/'+hash[0:5])
if res.status_code != 200:
print("Error talking to API")
sys.exit()
for line in res.text.split("\n"):
if hash[5:] in line:
x = line.split(":")
print("")
print("Your password is UNSAFE! Seen {} times in PwnedPasswords.com database".format(re.sub("[^0-9]","",x[1])))
sys.exit()
print("Your password is not in the PwnedPasswords.com database")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment