RandonautEntroPy/README.md

108 lines
2.9 KiB
Markdown
Raw Normal View History

2023-06-03 10:44:19 +03:00
# RandonautEntroPy
2023-05-28 22:49:23 +03:00
[![PyPI version](https://badge.fury.io/py/randonautentropy.svg)](https://pypi.org/project/randonautentropy/) [![PyPI - License](https://img.shields.io/pypi/l/randonautentropy)](https://pypi.org/project/randonautentropy/)
2023-06-03 11:41:24 +03:00
This project provides tools for interacting with the Randonautica QRNG and [Temporal](https://github.com/TheRandonauts/temporal) entropy generators. It provides a Python API, and a `rndo` command-line tool.
### Fair Use Policy
Please request only the entropy amount you really need for your project. Please note that in case of overuse the API is subject to immediate modifications and amendments to free availability.
Temporal on the other hand runs on your system and is always available.
2023-05-28 22:49:23 +03:00
## Installation
```
$ pip install randonautentropy
```
2023-06-03 10:44:19 +03:00
2023-06-03 11:41:24 +03:00
### Installing Temporal
The first time the `temporal.get` Python method or `rndo -t` command line option are called, a script attempts to automatically install the [TemporalLib](https://github.com/TheRandonauts/temporal) shell tool dependency in `/usr/local/bin`
In case that fails you can install it yourself:
```
$ sudo apt install git build-essential
$ git clone --depth 1 git@github.com:TheRandonauts/temporal.git
$ cd temporal
$ ./make.sh
```
2023-06-03 10:44:19 +03:00
---
2023-05-28 22:49:23 +03:00
## Python API
2023-06-02 00:58:58 +03:00
The randonautentropy Python module contains low-level `get` functions.
2023-05-28 22:49:23 +03:00
```Python
2023-06-02 00:58:58 +03:00
>>> from randonautentropy import rndo
>>> from randonautentropy import temporal
2023-05-28 22:49:23 +03:00
2023-06-02 00:58:58 +03:00
>>> rndo.get(length=10, type='hex16')
2023-05-28 22:49:23 +03:00
2023-06-02 00:58:58 +03:00
e5b779d67eda68636cb9
2023-05-28 22:49:23 +03:00
2023-06-03 10:44:19 +03:00
>>> temporal.get(length=10, channel=0)
d0c7ca53cb57ede1be14
```
### Extended Functionality
The `rndo.get` function can also retrieve a single 32bit random number in different formats:
```Python
2023-05-28 22:49:23 +03:00
>>> rndo.get(type='int32')
-968449906
>>> rndo.get(type='uniform')
0.9251141917698646
>>> rndo.get(type='normal')
0.8924809489412333
>>> rndo.get(type='base64')
JA==
2023-06-03 10:44:19 +03:00
```
The `temporal.get` method can switch from the default high quality entropy mode to a faster but slightly lower entropy mode by switching its `channel` to 1.
2023-06-02 00:58:58 +03:00
2023-06-03 10:44:19 +03:00
```Python
2023-06-02 00:58:58 +03:00
>>> temporal.get(channel=1)
b83a7fd79bee5b3b1ad7
2023-05-28 22:49:23 +03:00
```
2023-06-03 10:44:19 +03:00
---
2023-05-28 22:49:23 +03:00
## Command Line Interface
The package also comes with a `rndo` CLI:
```
2023-06-02 00:58:58 +03:00
usage: rndo [-h] [--rndo] [--temporal] [bytes]
2023-05-28 22:49:23 +03:00
A tool for printing random data from the Randonautica Quantum Random Number Generators
positional arguments:
2023-06-02 00:58:58 +03:00
bytes amount of hexadecimal bytes
2023-05-28 22:49:23 +03:00
options:
2023-06-02 00:58:58 +03:00
-h, --help show this help message and exit
--rndo, -r Hexadecimal QRNG entropy
--temporal, -t Hexadecimal Temporal entropy
2023-05-28 22:49:23 +03:00
```
### Example:
```
2023-06-02 00:58:58 +03:00
$ rndo -r 100
2023-05-28 22:49:23 +03:00
d204ab96505929325292d84a1217ded8de5781a449be0371cdcc97e6f6b1fe69a6b530cdf7112250172e573fe7b42b9e89fe42eef198cce0ec7a427b74f59b7b7a3d8ecabfc0f0051fe06104b1dd7f2a7d1626d7f66aac5afe002bdb255ec136d52405c2
2023-06-02 00:58:58 +03:00
$ rndo -t 100
93378573b635dc2b01ffd426068e6ccecbc2046fbc9598c1c41a4cbe0dcc8f62071202ea72d05b83581e8cd968cbd099ee0ccf37e9fbcd7d476bd4da6b1965434fc1a65302c732a06b6e5cebff37101a21926a34f1b236a4660a599c6ec93ae7296176fc
2023-05-28 22:49:23 +03:00
```