Cryptographically verifiable, distributed dependency reviews
Add the last reviewed version to Cargo.toml / [dependencies]:
fastrand = "1.8.0"
Please, use mobile in landscape.
Filter reviews clicking on the numbers in the summary.
Full column names in tooltip hints: rating Negative, rating Neutral, rating Positive, rating Strong, thoroughness, understanding, reviews count.
Generates random numbers using Wyrand algorithm (which is not
cryptographically secure, but ostensibly passes some popular tests — I didn't
verify that).
No unsafe
, no dependencies other than std (except on WASM, where it pulls
in instant
crate to get initial entropy).
By default, the generator is initialized from a hash of
std::time::Instant::now() and process ID. Good enough for a non-cryptographic
PRNG.
Interesting detail: if the thread-local storage has already been
de-initialized by we try to use it, the generator is initialized by a fixed
seed 0x4d595df4d0f33173. This constant is an initial state for PCG-XSH-RR,
which is an algorithm that previous versions of the crate used.
I verified that the algorithms match the documents they reference:
wyrand()
inI also verified that the algorithms that generate floating-point numbers
indeed do what they're supposed to do: set sign to 0 (i.e. positive),
exponent to 127 (i.e. zero), then fill the fraction with random bits, and
subtracting 1.0 from the result to get [0; 1).
Also worth mentioning that the crate doesn't guarantee a specific algorithm,
so you shouldn't depend on a specific seed to always produce the same
results.
Recommended for non-cryptographic purposes that do not require
reproducibility.
© bestia.dev 2023, MIT License, Version: 2023.608.1636
Open source repository for this web app: https://github.com/bestia-dev/cargo_crev_web/
Generates random numbers using Wyrand algorithm (which is not
cryptographically secure, but ostensibly passes some popular tests — I didn't
verify that).
No
unsafe
, no dependencies other than std (except on WASM, where it pullsin
instant
crate to get initial entropy).By default, the generator is initialized from a hash of
std::time::Instant::now() and process ID. Good enough for a non-cryptographic
PRNG.
Interesting detail: if the thread-local storage has already been
de-initialized by we try to use it, the generator is initialized by a fixed
seed 0x4d595df4d0f33173. This constant is an initial state for PCG-XSH-RR,
which is an algorithm that previous versions of the crate used.
I verified that the algorithms match the documents they reference:
wyrand()
inhttps://github.com/wangyi-fudan/wyhash/blob/master/wyhash.h at commit
399078afad15f65ec86836e1c3b0a103d178f15b
https://lemire.me/blog/2016/06/30/fast-random-shuffling/
https://stackoverflow.com/questions/28868367/getting-the-high-part-of-64-bit-integer-multiplication/28904636#28904636
I also verified that the algorithms that generate floating-point numbers
indeed do what they're supposed to do: set sign to 0 (i.e. positive),
exponent to 127 (i.e. zero), then fill the fraction with random bits, and
subtracting 1.0 from the result to get [0; 1).
Also worth mentioning that the crate doesn't guarantee a specific algorithm,
so you shouldn't depend on a specific seed to always produce the same
results.
Recommended for non-cryptographic purposes that do not require
reproducibility.