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), and more. It has a simple but powerful API. For example, a PRNG seed can be generated using strong entropy (using a hardware random number generator like /dev/random on Linux). The library is written in C, and a Python binding is available. The word "hasard" is the French word for "randomness" or "chance".
| Tags | Software Development Libraries Scientific/Engineering Physics Mathematics Python Modules |
|---|---|
| Licenses | BSD Revised |
| Operating Systems | POSIX |
| Implementation | Python C |
Recent releases


Changes: This release supports Mac OS X and big endian (PPC32) CPUs. tools/testu01.c, a TestU01 test suite, has been created. There is a new engine: dev_hardware (/dev/random, or /dev/srandom on OpenBSD). The profile "@secure" has been replaced by "@secure_nonblocking" and "@secure_blocking".


Changes: The result of hasard_double(a, b) is now in [a; b( instead of [a; b] form because most libraries use this convention. New KISS, libc_rand, and libc_rand48 engines were included along with a hasard_clone() function. "Weak" engines (minimum_standard, park_miller, randu, etc.) were moved to a new library (hasardweak) to keep only good RNG in the hasard library and to have a smaller memory footprint. The hasard_pow2() function was removed and hasard_ulong() is used instead to detect integer overflows at compile time. All public functions were documented and the Hasard version in which the function was introduced was specified.


Changes: This release creates the engines gcrypt_nonce, gcrypt_weak, gcrypt_strong, gcrypt_very_strong, gsl, gmp_mt, libc_rand, and libc_rand48. It has a new function hasard_shuffle() to mix elements of an array. glib and OpenSSL libraries and functions are now dynamically loaded (for a smaller memory footprint and easier compilation). This release reseeds the engine in a child process after a fork(). An examples directory ("hello world" and shuffle examples) has been added.


Changes: Windows support (creation of the cryptgen engine). The addition of OpenSSL and glib engines. Fixes for compiler issues (64-bit CPUs and ISO C). The "support" function has been removed: call directly a function to check whether it is supported or not.


Changes: The hasard_int8/16/32(), hasard_uint8/16/32(), and hasard_compare_version() functions were created. hasard_engine_ulong() was reimplemented using the algorithm from GSL, which has no more bias and only uses the unsigned long type (don't use GMP anymore). hasard_engine_pow2() now uses hasard_engine_ulong(). A version was added to the file format (plain text file). hasard_dev_bytes() doesn't fill a buffer with zeros on a read() error. The --quiet option was created for gen_files.py and file_info.py.