From 3b79f0c79b746cf5ccfde83c880f6628974cb684 Mon Sep 17 00:00:00 2001 From: Szczepan Zalega Date: Sat, 19 Sep 2020 18:12:31 +0200 Subject: Readme: collapse logs and code snippets --- README.md | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/README.md b/README.md index e6c6fd5..8ca185e 100644 --- a/README.md +++ b/README.md @@ -93,6 +93,11 @@ pip3 install cffi # for python 3.x ``` ## Python2 Just import it, read the C API header and it is done! You have access to the library. Here is an example (in Python 2) printing HOTP code for Pro or Storage device, assuming it is run in root directory [(full example)](python_bindings_example.py): + +
+ Log (click to show) + + ```python #!/usr/bin/env python2 import cffi @@ -159,11 +164,19 @@ print('Getting HOTP code from Nitrokey device: ') print(hotp_slot_code) libnitrokey.NK_logout() # disconnect device ``` + +
+ In case no devices are connected, a friendly message will be printed. All available functions for C and Python are listed in [NK_C_API.h](NK_C_API.h). Please check `Documentation` section below. ## Python3 Just import it, read the C API header and it is done! You have access to the library. Here is an example (in Python 3) printing HOTP code for Pro or Storage device, assuming it is run in root directory [(full example)](python3_bindings_example.py): + +
+ Code snippet (click to show) + + ```python #!/usr/bin/env python3 import cffi @@ -242,6 +255,8 @@ print(ffi.string(hotp_slot_code).decode('ascii')) libnitrokey.NK_logout() # disconnect device ``` +
+ In case no devices are connected, a friendly message will be printed. All available functions for C and Python are listed in [NK_C_API.h](NK_C_API.h). Please check `Documentation` section below. @@ -280,6 +295,10 @@ For additional documentation please check the following for [py.test installatio ## C++ tests There are also some unit tests implemented in C++, placed in unittest directory. The only user-data safe online test set here is [test_safe.cpp](https://github.com/Nitrokey/libnitrokey/blob/master/unittest/test_safe.cpp), which tries to connect to the device, and collect its status data. Example run for Storage: + +
+ Log (click to show) + ```text # Storage device inserted, firmware version v0.53 $ ./test_safe @@ -340,6 +359,10 @@ $ ./test_safe =============================================================================== All tests passed (18 assertions in 6 test cases) ``` + +
+ + Test's execution configuration and verbosity could be manipulated - please see `./test_safe --help` for details. The other tests sets are not written as extensively as Python tests and are rather more a C++ low level interface check used during the library development, using either low-level components, C API from `NK_C_API.cc`, or C++ API from `NitrokeyManager.cc`. Some of them are: [test_HOTP.cc](https://github.com/Nitrokey/libnitrokey/blob/master/unittest/test_HOTP.cc), -- cgit v1.2.3