From 0c8685e08ca4c4eb5e3ed5997d860e9e418fbb5a Mon Sep 17 00:00:00 2001 From: kaddi Date: Sun, 27 Jan 2019 11:41:02 +0100 Subject: [PATCH] added testpw.py testpw.py takes password as argument and checks it against haveibeenpawned or not in a secure way --- testpw.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 testpw.py diff --git a/testpw.py b/testpw.py new file mode 100644 index 0000000..42e88d5 --- /dev/null +++ b/testpw.py @@ -0,0 +1,17 @@ +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")