Skip to content


Folders and files

Last commit message
Last commit date

Latest commit


Repository files navigation

Tools for utilizing the ANU Quantum Random Numbers Server

This project provides tools for interacting with The ANU Quantum Random Number Generator ( It communicates with their JSON API and provides a qrandom command-line tool, a Python API, and a Linux /dev/qrandom character device.

quantumrandom works on Python 2 and 3.


As of version 1.7, quantumrandom now uses SSL/TLS by default.


pip install quantumrandom

Command-line tool

$ qrandom --int --min 5 --max 15
$ qrandom --binary
$ qrandom --hex
$ qrandom --binary | dd of=data
^C1752+0 records in
1752+0 records out
897024 bytes (897 kB) copied, 77.7588 s, 11.5 kB/s

Creating /dev/qrandom

quantumrandom comes equipped with a multi-threaded character device in userspace. When read from, this device fires up a bunch of threads to fetch data. Not only can you utilize this as a rng, but you can also feed this data back into your system's entropy pool.

In order to build it's dependencies, you'll need the following packages installed: svn, gcc-c++, fuse-devel, gccxml, libattr-devel. On Fedora 17 and newer, you'll also need the kernel-modules-extra package installed for the cuse module.


The /dev/qrandom character device currently only supports Python2

pip install ctypeslib==dev hg+
sudo modprobe cuse
sudo chmod 666 /dev/cuse
sudo chmod 666 /dev/qrandom

By default it will use 3 threads, which can be changed by passing '-t #' into the qrandom-dev.

Testing the randomness for FIPS 140-2 compliance

$ cat /dev/qrandom | rngtest --blockcount=1000
rngtest: bits received from input: 20000032
rngtest: FIPS 140-2 successes: 1000
rngtest: FIPS 140-2 failures: 0
rngtest: FIPS 140-2(2001-10-10) Monobit: 0
rngtest: FIPS 140-2(2001-10-10) Poker: 0
rngtest: FIPS 140-2(2001-10-10) Runs: 0
rngtest: FIPS 140-2(2001-10-10) Long run: 0
rngtest: FIPS 140-2(2001-10-10) Continuous run: 0
rngtest: input channel speed: (min=17.696; avg=386.711; max=4882812.500)Kibits/s
rngtest: FIPS tests speed: (min=10.949; avg=94.538; max=161.640)Mibits/s
rngtest: Program run time: 50708319 microseconds

You can utilize the rngtest tool in pipe mode to ensure that all of your data is FIPS 140-2 compliant:

$ cat /dev/qrandom | rngtest --pipe

Adding entropy to the Linux random number generator

sudo rngd --rng-device=/dev/qrandom --random-device=/dev/random --foreground

Monitoring your available entropy levels

watch -n 1 cat /proc/sys/kernel/random/entropy_avail

Python API

The quantumrandom Python module contains a low-level get_data function, which is modelled after the ANU Quantum Random Number Generator's JSON API. It returns variable-length lists of either uint16 or hex16 data.

>>> quantumrandom.get_data()
>>> quantumrandom.get_data(data_type='uint16', array_length=5)
[42796, 32457, 9242, 11316, 21078]
>>> quantumrandom.get_data(data_type='hex16', array_length=5, block_size=2)
['f1d5', '0eb3', '1119', '7cfd', '64ce']

Valid data_type values are uint16 and hex16, and the array_length and block_size cannot be larger than 1024. 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.

Based on this get_data function, quantumrandom also provides a bunch of higher-level helper functions that make easy to perform a variety of tasks.

>>> quantumrandom.randint(0, 20)
>>> quantumrandom.hex()[:10]
>>> quantumrandom.binary()[0]
>>> len(quantumrandom.binary())
>>> quantumrandom.uint16()
numpy.array([24094, 13944, 22109, 22908, 34878, 33797, 47221, 21485, 37930, ...], dtype=numpy.uint16)
>>> quantumrandom.uint16().data[:10]


Tools for utilizing the ANU Quantum Random Number Generator






No packages published