rand_otp 0.1.0

Pregenerated random numbers.

One Time Pad for rand.


This is useful when you want to control the sequence of generated numbers. One example use case is for fuzz-testing programs that pull values from a RNG. Using a PRNG would result in basically brute-force fuzzing while using rand_otp allows guided-fuzzing to be effective.

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());