[Q]:Generate Unique ID's

Paul Rubin http
Sat May 24 00:32:53 EDT 2003


achrist at easystreet.com writes:
> Does the typical Intel chip have a piece of random hardware
> that returns something that's more random than pseudo-random?

The Pentium III chipset has a device like that as does the new Via
CPU, but it's certainly not a universal feature.

> If so, can Python access this? 

Not from the standard library.  It would be an OS function, not a
Python function.  In Linux there's a special file called /dev/urandom
that you can read random bytes from.  In Windows, there's a CAPI
function called CryptGenRandom which does something similar.  There's
a Python module that calls CryptGenRandom that I guess I can send
you a copy of, but it's not in the standard library.

> If so, why have people been busting tails to implement and
> improve the Mersennes twister?

I think that using the Mersenne twister was a mistake given that it
replaced the WH generator that was already unsatisfactory.  I think
they should have stopped fooling around and used a cryptographic RNG.
Replacing an unsatisfactory RNG with a semi-satisfactory one doesn't
seem that worthwhile a move.

> What's the truly random algorithm?  If it's pseudo-random, 
> don't I have the same problem initializing the algorithm?

Yes, it's a real problem and it has to be done at low levels of the
OS.  However, there are some genuine sources of randomness in a PC,
like the precise timings of disk read operations, that are affected by
chaotic airflow inside the drive.  There are a lot of academic papers
on this subject.  Linux's /dev/urandom is driven from an entropy
gatherer that uses timings of various other hardware interrupts as
well, and maybe the CPU performance counters which are incremented on
every CPU clock tick.  The documentation for CryptGenRandom mentions
that it's one of the hardest CAPI functions for implementers to get
right.




More information about the Python-list mailing list