rand_otp 0.1.0

Pregenerated random numbers.
Documentation
  • Coverage
  • 0%
    0 out of 3 items documented0 out of 3 items with examples
  • Size
  • Source code size: 7.32 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 332.21 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Links
  • Homepage
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • kevincox

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