Package: quantumrand
QuantumRandmaintained fork oflmacken/quantumrandomThis project provides tools for interacting with The ANU Quantum Random Number Generator (qrng.anu.edu.au). It communicates with their JSON API and provides a Python API,aqrandcommand-line tool, and a Linux/dev/qrandcharacter device.(This has to be fixed).QuantumRand was made to work with Python 3. Python 2 support has been dropped as it is now reached End of Life.As of 2.0, QuantumRand has had to adapt to ANU's SSL certificate expiring. QuantumRand is still able to connect via SSL by default, but please be aware that QuantumRand cannot securely validate ANU's SSL authenticity until they update their certificate.Installationpip install quantumrandPython APILow Level API ExamplesThe QuantumRand Python module contains a low-levelget_datafunction, which is modelled after the ANU Quantum Random Number
Generator's JSON API. It returns variable-length lists of eitheruint16orhex16data.Validdata_typevalues areuint16andhex16.Thearray_lengthandblock_sizecannot be larger than1024.If for some reason the API call is not successful, or the incorrect amount of data is returned from the server, this function will raise an exception.quantumrand.get_data()[26646]quantumrand.get_data(data_type='uint16', array_length=5)[42796, 32457, 9242, 11316, 21078]quantumrand.get_data(data_type='hex16', array_length=5, block_size=2)['f1d5', '0eb3', '1119', '7cfd', '64ce']High Level API ExamplesBased on the aboveget_datafunction, quantumrand also provides a bunch
of higher-level helper functions that make easy to perform a variety of
tasks.Generate a random intgerquantumrand.randfloat(0, 20)18.936751354238194quantumrand.randint(0, 20)5Generate random HEX as a stringquantumrand.hex()[:10]'8272613343'Generate random binary formatted stringquantumrand.binary()[:3]'\xa5\x0d\x1e'The previousbinary()function returns 10000 byteslen(quantumrand.binary())10000Generate uint16 values as a Numpy arrayquantumrand.uint16()numpy.array([24094, 13944, 22109, 22908, 34878, 33797, 47221, 21485, 37930, ...], dtype=numpy.uint16)Randomly select an item from a listquantumrand.list_picker(["Mary", "Bill", "Chad", "Nicole"])"Nicole"Dice rollingThe two main methods aredice_roll()andquick_dice()Both methods can take 3 optional arguments:nis the number of dice to roll (default is1)dis the number of sides on each die (default is6)minis the lowest number on the die (default is1)dice_roll()returns a tuple where the first value is a list of individual dice rolls, and the second value is the total of the dice rolls.quick_dice()returns an integer with the total dice rolls. This is best for single die rolls and dice rolls you don't need to know the individual rolls of.Roll a single d6 (a standard 6 sided die) and show resultsquantumrand.dice_roll()([3], 3)Roll a single d20 and show resultsquantumrand.dice_roll(d=20)([19], 19)Roll two d9 (0-9) and show resultsquantumrand.dice_roll(d=9, n=2, min=0)([0,3], 3)Roll three d8 and show resultsquantumrand.dice_roll(d=8, n=3)([4,8,3], 15)Roll three d9 (0-9) and show only the total.quantumrand.quick_dice(d=9, n=3, min=0)24You can roll a die with any number of sidesquantumrand.quick_dice(d=67)1Using the Command Line ToolCurrently still being fixed!Getting a random integer within a range:qrand --int --min 5 --max 157Getting random binary values:qrand --binary���I�%��e(�1��c��Ee�4�������j�Կ��=�^H�c�u
oq��G��Z�^���fK�0_��h��s�b��AE=�rR~���(�^Q�)4��{c�������X{f��a�Bk�N%#W
+a�a̙�IB�,S�!ꀔd�2H~�X�Z����R��.fGetting random hex values:qrand --hex1dc59fde43b5045120453186d45653dd455bd8e6fc7d8c591f0018fa9261ab2835eb210e8
e267cf35a54c02ce2a93b3ec448c4c7aa84fdedb61c7b0d87c9e7acf8e9fdadc8d68bcaa5aCreating /dev/qrandThis will have to be updated, as it is not working for any supported version of Python currently.