[Tutor] What are these things urandom() returns?
Terry Carroll
carroll at tjc.com
Thu Oct 12 02:54:39 CEST 2006
On Wed, 11 Oct 2006, Tim Peters wrote:
> If you want /true/ randomness, you can buy a certified hardware random
> number generator, based on non-deterministic physical processes (like
> timing radioactive decay, or measuring thermal noise).
Why buy when you can borrow?:
def truerandom(n):
"""
truerandom(n) --> str
Return a string of n truly random bytes.
see:
http://www.fourmilab.ch/hotbits/
http://www.fourmilab.ch/hotbits/generate.html
"""
import urllib
_url = "http://www.fourmilab.ch/cgi-bin/Hotbits?nbytes=%s&fmt=bin" % n
return urllib.urlopen(_url).read()
More information about the Tutor
mailing list