Skip to content

Instantly share code, notes, and snippets.

@venil7
Created August 6, 2017 15:08
Show Gist options
  • Save venil7/90a1f014c220d7a138d1d0f3bed08cf0 to your computer and use it in GitHub Desktop.
Save venil7/90a1f014c220d7a138d1d0f3bed08cf0 to your computer and use it in GitHub Desktop.
# https://downloads.pwnedpasswords.com/passwords/pwned-passwords-1.0.txt.7z
# https://downloads.pwnedpasswords.com/passwords/pwned-passwords-update-1.txt.7z
import hashlib
def _hash(password):
p = password.encode('utf-8')
m = hashlib.sha1()
m.update(p)
return m.hexdigest().upper()
pwdfile = open('/path/to/passwords.txt')
pwds = []
for pwd in pwdfile:
p1 = _hash(pwd.rstrip())
p2 = _hash(pwd.rstrip().lower())
pwds.append(p1)
if p1 != p2:
pwds.append(p2)
pwnfile = open('/path/to/pwned-passwords-update-1.txt')
matches = []
for pwn in pwnfile:
if pwn.rstrip() in pwds:
matches.append(pwn.rstrip())
print(matches)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment