Hasard documentation index¶
Hasard is a pseudo-random number generator (PRNG) library. It includes multiple engines (algorithms): Park-Miller, Mersenne Twister, Linux device (/dev/urandom or /dev/random), ... It has simple API but with strong code, eg. PRNG seed can be generated using strong entropy (hardware random number generator like /dev/random on Linux).
The library is written in C and a Python binding is available. The library is distributed under BSD license. The word “hasard” is the french name of “randomness” or “chance”.
- Simple API with high level functions and uniform distribution
- Generic functions to get/set generator seed and state, and to reseed the generator
- Reuse existing libraries: OpenSSL, gcrypt, GSL, GMP, glib, etc.
- Informations about the generator: name, min/max period, tick range, etc.
Why using Hasard instead of just rand() or /dev/urandom?¶
It’s hard to write algorithms with uniform distribution and most people write buggy functions. Hasard initializes the generator seed from a good entropy source (not the current time or process identifier). Hasard code is also tested by unit tests to ensure that the number distribution is correct.
Hasard always choose the best generator depending of the available generators, eg. use gcrypt_strong if openssl_secure is not available.
Read doc/common_errors.rst document for more information about common errors in pseudo-random number generators.
Hasard User documentation¶
- Install Hasard library
- Hasard API
- 64-bit integers
- Clone a generator
- Generate random numbers
- Generate an array of random numbers
- Generate other kind of random values
- Shuffle an array
- Set generator direction
- Get and set the state of a generator
- Get and set the seed
- Get informations about the engines
- Low level functions
- Error handling
- Library version
- Other functions
- Hasard profile list
- Engine list
- Common errors in pseudo-random number generators
Random number generators documentation¶
- Random number generators
- Linear congruential generators
- Linux kernel devices
- Operating system services
- Usage of RNG in applications and libraries
Hasard hacker documentation¶
- 2013-12-17: Hasard 1.5, 4 years later!
- 2009-08-22: Hasard 1.0
- 2009-07-23: Hasard 0.9.7
- 2009-07-09: Hasard 0.9.6
- 2009-07-07: Hasard 0.9.5
- 2009-06-13: Hasard 0.9
- 2009-05-12: Hasard 0.8
Read also the ChangeLog.
- OpenSSL includes PRNG
- libgcrypt includes PRNG
- Pseudo-Random Number Generator (PRNG) by Otmar Lendl and Josef Leydold
- Python language includes its own random library written in Python (random.py)
- GNU Scientific Library (GSL)
- Boost Random Number Library
- The Scalable Parallel Random Number Generators Library (SPRNG)
- pLab-package: The pLab-package includes portable high-performance implementations of the linear congruential, quadratic congruential, inversive congruential, and explicit inversive congruential random number generators (LCG, QCG, ICG, and EICG, respectively), which were designed and implemented by Otmar Lendl.