![]() | |
#1
| |||
| |||
|
#2
| ||||
| ||||
|
|
I've noticed that rand() do not change on each query request. Is there a = way=20 I could get a TRUE randominess into MySQL? |
|
rand(3) | rand() | rand() | +------------------+------------------+------------------+ 0.18109050875631 | 0.75023213843837 | 0.20788919665654 | +------------------+------------------+------------------+ |
|
rand() | rand() | rand() | +------------------+------------------+------------------+ 0.78874959870125 | 0.32008043427028 | 0.23415340598128 | +------------------+------------------+------------------+ |
|
rand(3) | rand() | rand() | +------------------+------------------+------------------+ 0.18109050875631 | 0.75023213843837 | 0.20788919665654 | +------------------+------------------+------------------+ |
#3
| |||
| |||
|
|
However, in answer to your question, there is no way to get TRUE randomness in a computer system. Even cryptographically secure random number generators can be predicted under absolutely identical circumstances. |
#4
| |||
| |||
|
|
There are also several places that you can get a reasonably random=20 number for the seed from your machine. The amount of free disk space,=20 unless that doesn't change much on your machine. The amount of free=20 RAM, (up time mod cpu usage). Any number of things could be used that=20 are not very predictable, if at all. |
#5
| |||
| |||
|
|
On Thu, 2005-08-04 at 14:44 -0500, 2wsxdr5 wrote: There are also several places that you can get a reasonably random number for the seed from your machine. The amount of free disk space, unless that doesn't change much on your machine. The amount of free RAM, (up time mod cpu usage). Any number of things could be used that are not very predictable, if at all. But again, those aren't truely random. They're random-enough for the average web applications. The original poster, if memory serves, asked if it was possible to get true random numbers from MySQL. True random numbers can't be predicted even if I know everything about your system. Because computers are predictable beasts, the random number generators that they used are constrained by the hardware limits. |
#6
| |||
| |||
|
|
=20 Pat Adams <adams.patrick (AT) dallas (DOT) sysco.com> writes: =20 On Thu, 2005-08-04 at 14:44 -0500, 2wsxdr5 wrote: There are also several places that you can get a reasonably random number for the seed from your machine. The amount of free disk space, unless that doesn't change much on your machine. The amount of free RAM, (up time mod cpu usage). Any number of things could be used that are not very predictable, if at all. But again, those aren't truely random. They're random-enough for the average web applications. The original poster, if memory serves, asked if it was possible to get true random numbers from MySQL. True random numbers can't be predicted even if I know everything about your system. Because computers are predictable beasts, the random number generators that they used are constrained by the hardware limits. =20 /dev/random is a source of some genuine entropy on many Unix-like operating systems. It uses variations in system timings that are believed to be truly random. It's not good for a large volume of output, but it's a good seed. You could probably incorporate access to it or its friend /dev/urandom as a UDF: =20 http://sunsite.mff.cuni.cz/MIRRORS/f...dding_UDF.html =20 EGD (Entropy Gathering Daemon) is an option for other Unix-like systems: =20 http://egd.sourceforge.net/ =20 or you can use a Lava Lamp: =20 http://www.lavarnd.org/index.html =20 I'm sure Windows has some way to do this, too. =20 Many systems also have an onboard random number generator which you should be able to access through an OS driver. =20 ----ScottG. =20 -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/mysql?unsub=3...mail (DOT) com =20 Thanks for the wonderful sources! |
![]() |
| Thread Tools | |
| Display Modes | |
| |