From adb086785942232ebc48b521ded7cee4f6232194 Mon Sep 17 00:00:00 2001 From: Szczepan Zalega Date: Fri, 5 Jan 2018 10:05:00 +0100 Subject: Handle getting HOTP code properly Signed-off-by: Szczepan Zalega --- python_bindings_example.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'python_bindings_example.py') diff --git a/python_bindings_example.py b/python_bindings_example.py index 1740a76..7bb806c 100755 --- a/python_bindings_example.py +++ b/python_bindings_example.py @@ -59,7 +59,7 @@ def get_library(): def get_hotp_code(lib, i): - return lib.NK_get_hotp_code(i) + return get_string(lib.NK_get_hotp_code(i)) def to_hex(ss): return ''.join([ format(ord(s),'02x') for s in ss ]) @@ -113,5 +113,6 @@ test_data = [ print('Getting HOTP code from Nitrokey Pro (RFC test, 8 digits): ') for i in range(10): hotp_slot_1_code = get_hotp_code(libnitrokey, 1) - print('%d: %d, should be %s' % (i, hotp_slot_1_code, str(test_data[i])[-8:] )) + correct_str = "correct!" if hotp_slot_1_code == str(test_data[i])[-8:] else "not correct" + print('%d: %s, should be %s -> %s' % (i, hotp_slot_1_code, str(test_data[i])[-8:], correct_str)) libnitrokey.NK_logout() # disconnect device -- cgit v1.2.1