1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
extern crate rand; use self::rand::{OsRng, Rng}; use types::*; pub struct RandomOs { rng : OsRng } impl Default for RandomOs { fn default() -> RandomOs { RandomOs {rng: OsRng::new().unwrap()} } } impl Random for RandomOs { fn fill_bytes(&mut self, out: &mut [u8]) { self.rng.fill_bytes(out); } }