Skip to content
This repository was archived by the owner on Nov 1, 2024. It is now read-only.

Commit 2f6cf88

Browse files
committed
fix for #3
1 parent b723255 commit 2f6cf88

2 files changed

Lines changed: 11 additions & 1 deletion

File tree

kdbxpasswordpwned.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ def build_parser():
2020

2121

2222
def check_hash(password):
23-
h = hashlib.sha1(password.encode()).hexdigest().upper()
23+
password = password.encode('utf-8')
24+
h = hashlib.sha1(password).hexdigest().upper()
2425
hh = h[5:]
2526
for l in requests.get('https://api.pwnedpasswords.com/range/' + h[:5]).content.decode().splitlines():
2627
ll = l.split(':')

tests.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,15 @@ def test_issue_4(self, ch_mock, gp_mock):
154154
self.assertEqual(fout[0].getvalue(), '')
155155
ch_mock.assert_not_called()
156156

157+
@mock.patch('requests.get')
158+
def test_issue_3(self, req_mock):
159+
'''
160+
https://github.com/fopina/kdbxpasswordpwned/issues/3
161+
issue_3.kdbx takes seconds to load, so importing the
162+
actual issue directly to the test
163+
'''
164+
_val = u'\xc7\xf6\xf6\xb5\xe6\xaf\xe1\xe2\xb4\xb2\xe5\xaf\xd5\xb7\xaf\xa3\xa1\xcf\xff\xcb\xdb\xa7\xd2\xf7\xb5\xb8\xab\xfc\xbd\xd7\xb7\xe8\xfb\xfa\xc9\xa6\xe5\xe2\xb8\xf8\xf1\xdb\xa4\xfc\xbc\xd4\xba\xd1\xa4\xde\xa4\xd7\xc7\xaa\xb4\xc5\xc4\xe7\xce\xe9\xe6\xd2\xcd\xd4\xeb\xd7\xb0\xef\xa5\xba\xbb\xbf\xac\xf4\xca\xf3\xb2\xd7\xc1\xe9\xeb\xf4\xb9\xb5\xd6\xf2\xd3\xf6\xca\xd2\xa7\xd5\xeb\xbf\xda\xc1\xca\xc4\xac\xd2\xe4\xd9\xbd\xed\xa5\xdd\xb2\xcb\xff\xd6\xe5\xd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