Files
gists/testpw.py
kaddi 0c8685e08c added testpw.py
testpw.py takes password as argument and checks it against
haveibeenpawned or not in a secure way
2019-01-27 11:41:02 +01:00

18 lines
422 B
Python

import sys
import hashlib
import requests
url="https://api.pwnedpasswords.com/range/"
hash_object = hashlib.sha1(sys.argv[1].encode("UTF-8"))
pw_hash=hash_object.hexdigest()
first_part=pw_hash[:5]
second_part=pw_hash[5:]
print(pw_hash)
print(first_part)
print(second_part)
furl="{}{}".format(url,first_part)
print(furl)
response=requests.get(furl)
if second_part.lower() in response.text.lower():
print("hash found")