hwrng
Modern rasbperrypi’s have /dev/hwrng
and rng-tools
already installed.
This
is a pretty old post, but it has the salient details for making sure it is enabled and checking it.
Also the bit about editing /etc/default/rng-tools
to enable the device.
The device is only readable by root by default (probably can change this with chown,
but I haven’t looked). Update: this page has the details for making /dev/hwrng
readable for users.
r = None
with open("/dev/hwrng", "rb") as d:
r = d.read(10)
print(int.from_bytes(r, byteorder="big"))