Skip to content

Commit

Permalink
fix for #3
Browse files Browse the repository at this point in the history
  • Loading branch information
fopina committed Jan 27, 2019
1 parent b723255 commit 2f6cf88
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
3 changes: 2 additions & 1 deletion kdbxpasswordpwned.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ def build_parser():


def check_hash(password):
h = hashlib.sha1(password.encode()).hexdigest().upper()
password = password.encode('utf-8')
h = hashlib.sha1(password).hexdigest().upper()
hh = h[5:]
for l in requests.get('https://api.pwnedpasswords.com/range/' + h[:5]).content.decode().splitlines():
ll = l.split(':')
Expand Down
9 changes: 9 additions & 0 deletions tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,15 @@ def test_issue_4(self, ch_mock, gp_mock):
self.assertEqual(fout[0].getvalue(), '')
ch_mock.assert_not_called()

@mock.patch('requests.get')
def test_issue_3(self, req_mock):
'''
https://github.com/fopina/kdbxpasswordpwned/issues/3
issue_3.kdbx takes seconds to load, so importing the
actual issue directly to the test
'''
_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\xd8\xa8\xda\xeb\xc5\xcd\xd5\xf9\xf9\xbf\xe0\xce\xaf\xdd\xb3\xfc\xd8\xb3\xda\xc0\xd1\xd1\xb9\xd9\xc9\xb7\xe6\xfe\xc0\xc5\xb3\xf7\xd8\xa3\xe2\xd6\xc4\xda\xf4\xc0\xea\xdf\xe0\xc0\xc3\xfb\xeb\xc0\xec\xb5\xc5\xbf\xfa\xec\xd5\xe5\xeb\xe7\xfc\xda\xe3\xfc\xe6\xdb\xc6\xb1\xf8\xa4\xf2\xed\xf3\xc2\xb5\xb5\xe0\xb3\xd0\xf4\xf6\xa6\xb3\xa1\xcd\xd9\xa1\xd5\xcb\xa6\xef\xa3\xbb\xbf\xea\xd5\xf3\xdc\xfe\xc4\xa2\xc8\xaa\xc9\xd6\xd0\xc3\xdb\xc0\xa7\xd3\xef\xce\xf7\xcc\xa7\xd2\xbb\xd9\xea\xf2\xb3\xab\xd5\xe4\xfb\xd3\xcd\xda\xab\xe2\xdd\xea\xda\xd1\xa8\xfe\xec\xba\xcb\xe7\xd3\xce\xa1\xaf\xdf\xed'
kdbxpasswordpwned.check_hash(_val)


def _asset(name):
Expand Down

0 comments on commit 2f6cf88

Please sign in to comment.