[−][src]Module win_crypto_ng::random
Cryptographically secure random number generation
Usage
To generate cryptographically secure random numbers, start by opening a
RandomNumberGenerator
. This can be done either via the open
method
where you specify the random algorithm to use or with the system_preferred
method, where the system default is used. Then, to fill a buffer with random
numbers, call the gen_random
method.
use win_crypto_ng::random::{RandomAlgorithmId, RandomNumberGenerator}; let mut buffer = [0u8; 32]; let rng = RandomNumberGenerator::open(RandomAlgorithmId::Rng).unwrap(); rng.gen_random(&mut buffer).unwrap(); assert_ne!(&buffer, &[0u8; 32]);
Structs
RandomNumberGenerator | Random number generator |
Enums
RandomAlgorithmId | Random number generation algorithms identifiers |