Merge pull request #10 from d-chris/master
changed password encoding to utf-8 for sha-1
This commit is contained in:
commit
af78272fdc
9
pwned.py
9
pwned.py
@ -1,7 +1,12 @@
|
||||
import hashlib
|
||||
import requests
|
||||
import sys
|
||||
|
||||
try:
|
||||
import requests
|
||||
except ModuleNotFoundError:
|
||||
print("### pip install requests ###")
|
||||
raise
|
||||
|
||||
|
||||
def lookup_pwned_api(pwd):
|
||||
"""Returns hash and number of times password was seen in pwned database.
|
||||
@ -18,7 +23,7 @@ def lookup_pwned_api(pwd):
|
||||
RuntimeError: if there was an error trying to fetch data from pwned
|
||||
database.
|
||||
"""
|
||||
sha1pwd = hashlib.sha1(pwd.encode('ascii')).hexdigest().upper()
|
||||
sha1pwd = hashlib.sha1(pwd.encode('utf-8')).hexdigest().upper()
|
||||
head, tail = sha1pwd[:5], sha1pwd[5:]
|
||||
url = 'https://api.pwnedpasswords.com/range/' + head
|
||||
res = requests.get(url)
|
||||
|
Loading…
Reference in New Issue
Block a user