1个不稳定版本
0.1.0 | 2019年12月10日 |
---|
#17 在 #pre-generated
4KB
67 行
rand的一次性填充
当你想要控制生成数字的序列时很有用。一个用例示例是用于模糊测试从RNG中提取值的程序。使用PRNG将导致基本上是暴力模糊测试,而使用rand_otp
则允许引导模糊测试有效。
let buf = [1, 2, 3, 4];
let mut rng = Otp::new(&buf[..]);
assert_eq!(rng.next_u32(), 0x04030201);
// Read random values from a file (or from a random device).
let f = std::fs::File::open("/dev/urandom").unwrap();
let mut rng = Otp::new(f);
eprintln!("Random: {}", rng.next_u64());
依赖关系
~520KB