The Cloudflare Randomness Printer prints on demand a 'receipt' containing the following:
-
A random number less than 1,000,000
-
A six word diceware password
-
Three passwords that have 128-bits of entropy. One has just hexadecimal digits, one has alphanumerics and another printable ASCII.
-
A random response from the Magic 8 Ball.
-
A QR code containing the information from 1 to 4.
-
A maze generated using Prim's Algorithm using a modified version of this code to make it more legible on the printer.
-
A random Sudoku generated using a modified version of this code.
-
The current UTC date and time in ISO8601 format.
The specific printer used is a GSAN 5870W Thermal Receipt Printer but the code will work with other printers that handle the ESC/POS format (which is very common). This specific printer was only used because we had one lying around.
The program uses /dev/urandom which is fed with entropy from Cloudflare's internal randomness source (such as lava lamps)
The code above runs on a Raspberry Pi Model B with an
LED
and a button connected
to two GPIO ports. Pressing the button simply executes ep.py
. It
uses code similar to this:
import RPi.GPIO as GPIO
import time, os
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
GPIO.setup(18, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setup(25, GPIO.OUT)
while True:
input_state = GPIO.input(18)
if input_state == False:
GPIO.output(25, GPIO.HIGH)
os.system("python ep.py")
GPIO.output(25, GPIO.HIGH)
time.sleep(0.01)
The button is connected between GND and GPIO18. The LED is connected between GND and GPIO25 with a 330 Ohm resistor to GND.