I am asked:
Using your raspberry pi, write a python script that determines the randomness
of /dev/random and /dev/urandom. Read bytes and histogram the results.
Plot in matplotlib. For your answer include the python script.
I am currently lost on the phrasing “determines the randomness.”
I can read from urandom and random with:
#rb - reading as binary
devrndm = open("/dev/random", 'rb')
#read to a file instead of mem?
rndmdata = devrndm.read(25) #read 25bytes
or
with open("/dev/random", 'rb') as f:
print repr(f.read(10))
I think the purpose of this exercise was to find out that urandom is faster and has a larger pool than random. However if I try to read anything over ~15 the time to read seems to increase exponentially.
So I am lost right now on how to compare ‘randomness’. If I read both urandom and random in to respective files how could I compare them?
Could it be as simple as:
ie. asking for 256 bytes doesn’t give back 256 unique values. So you could plot increasing sample sizes against the unique count until it reaches the 256 saturation point.