1 unstable release

0.1.0 Dec 10, 2019

#17 in #pre-generated

Apache-2.0

4KB
67 lines

One Time Pad for rand.

Docs

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

Dependencies

~520KB