Skip to content

Instantly share code, notes, and snippets.

import hashlib
import urllib.request
def lookup_passwd(passwd: str, verbose: bool=False) -> int:
# see: https://haveibeenpwned.com/API/v3#PwnedPasswords
sha1passwd = hashlib.sha1(passwd.encode()).hexdigest().upper()
head, tail = sha1passwd[:5], sha1passwd[5:]
url = 'https://api.pwnedpasswords.com/range/' + head
with urllib.request.urlopen(url) as f: