aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md23
1 files changed, 23 insertions, 0 deletions
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):
+
+<details>
+ <summary>Log (click to show)</summary>
+
+
```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
```
+
+</details>
+
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):
+
+<details>
+ <summary>Code snippet (click to show)</summary>
+
+
```python
#!/usr/bin/env python3
import cffi
@@ -242,6 +255,8 @@ print(ffi.string(hotp_slot_code).decode('ascii'))
libnitrokey.NK_logout() # disconnect device
```
+</details>
+
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:
+
+<details>
+ <summary>Log (click to show)</summary>
+
```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)
```
+
+</details>
+
+
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),