PRNG • ⼜稱為定性隨機比特⽣成器Deterministic random bit generators (DRBGs) • 密碼學安全偽亂數⽣成器 Cryptographically secure pseudorandom number generator,簡稱 CSPRNG 由物理世界的現象產出亂數(不具有確定性): • 真亂數⽣成器 True random number generator,簡稱 TRNG • ⼜稱為非定性隨機比特⽣成器 • non-deterministic random bit generators (NRBGs)
RAND_MAX assumed to be 32767 */ { next = next * 1103515245 + 12345; return((unsigned int)(next/65536) % 32768); } void mysrand(unsigned int seed) { next = seed; }
of this random number generator used the RC4 (also known as ARC4) algorithm. In OpenBSD 5.5 it was replaced with the ChaCha20 cipher, and it may be replaced again in the future as cryptographic techniques advance. A good mnemonic is “A Replacement Call for Random”.
the system generator is automatically seeded and thread-safe on every /// platform, the cryptographic quality of the stream of random data produced by /// the generator may vary. For more detail, see the documentation for the APIs /// used by each platform. /// /// - Apple platforms use `arc4random_buf(3)`. /// - Linux platforms use `getrandom(2)` when available; otherwise, they read /// from `/dev/urandom`. /// - Windows uses `BCryptGenRandom`.