Random number generator (device): Difference between revisions

Content added Content deleted
m (→‎{{header|Phix}}: tested on 0.8.2 (not that my cpu has magically gotten rdrand))
m (Regularize non-standard header markup)
Line 355: Line 355:
}</lang>
}</lang>


=== {{libheader|BSD libc}} ===
==={{libheader|BSD libc}}===
[http://www.openbsd.org/cgi-bin/man.cgi?query=arc4random&apropos=0&sektion=3&manpath=OpenBSD+Current&arch=i386&format=html arc4random()] appeared in [[OpenBSD]] 2.1 and has spread to many [[BSD]] systems. This function runs an ARC4 random number generator that takes entropy from a kernel device. (This kernel device is sysctl kern.arandom in OpenBSD, or /dev/urandom in some other systems.)
[http://www.openbsd.org/cgi-bin/man.cgi?query=arc4random&apropos=0&sektion=3&manpath=OpenBSD+Current&arch=i386&format=html arc4random()] appeared in [[OpenBSD]] 2.1 and has spread to many [[BSD]] systems. This function runs an ARC4 random number generator that takes entropy from a kernel device. (This kernel device is sysctl kern.arandom in OpenBSD, or /dev/urandom in some other systems.)


Line 369: Line 369:
}</lang>
}</lang>


=== {{libheader|OpenSSL}} ===
==={{libheader|OpenSSL}}===
OpenSSL can generate random numbers. The default generator uses SHA1. For [[Unix]] systems, OpenSSL will gather entropy by reading a kernel device like /dev/urandom, or by using [http://egd.sourceforge.net/ EGD, the Entropy Gathering Daemon]. For other systems, OpenSSL might use a different source of entropy.
OpenSSL can generate random numbers. The default generator uses SHA1. For [[Unix]] systems, OpenSSL will gather entropy by reading a kernel device like /dev/urandom, or by using [http://egd.sourceforge.net/ EGD, the Entropy Gathering Daemon]. For other systems, OpenSSL might use a different source of entropy.


Line 418: Line 418:
}</lang>
}</lang>


== {{header|C++}} ==
=={{header|C++}}==
<code>std::random_device</code> is a uniformly-distributed integer random number generator that produces non-deterministic random numbers.
<code>std::random_device</code> is a uniformly-distributed integer random number generator that produces non-deterministic random numbers.


Line 481: Line 481:
}</lang>
}</lang>


== {{header|ChucK}} ==
=={{header|ChucK}}==
<lang c> Math.random2(-(Math.random()),Math.random(); </lang>
<lang c> Math.random2(-(Math.random()),Math.random(); </lang>