aboutsummaryrefslogtreecommitdiff
path: root/python_bindings_example.py
diff options
context:
space:
mode:
authorSzczepan Zalega <szczepan@nitrokey.com>2018-01-05 10:05:00 +0100
committerSzczepan Zalega <szczepan@nitrokey.com>2018-01-05 10:07:28 +0100
commitadb086785942232ebc48b521ded7cee4f6232194 (patch)
tree75a168cc60d5a520e98b08039a6dfa6784d195fb /python_bindings_example.py
parentd917909036585eabeaa2e2727fca1d3d8cf9d086 (diff)
downloadlibnitrokey-adb086785942232ebc48b521ded7cee4f6232194.tar.gz
libnitrokey-adb086785942232ebc48b521ded7cee4f6232194.tar.bz2
Handle getting HOTP code properly
Signed-off-by: Szczepan Zalega <szczepan@nitrokey.com>
Diffstat (limited to 'python_bindings_example.py')
-rwxr-xr-xpython_bindings_example.py5
1 files changed, 3 insertions, 2 deletions
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