summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/rand.rs25
1 files changed, 2 insertions, 23 deletions
diff --git a/src/rand.rs b/src/rand.rs
index 404e115..aa322ba 100644
--- a/src/rand.rs
+++ b/src/rand.rs
@@ -5,34 +5,13 @@ use std::time::SystemTime;
static STATE: Mutex<u64> = Mutex::new(0);
-fn seed_urandom() -> Option<()> {
- let mut f = File::open("/dev/urandom").ok()?;
- let mut bytes = [0; 8];
- f.read_exact(&mut bytes).ok()?;
-
- *STATE.lock().unwrap() = u64::from_ne_bytes(bytes);
- return Some(());
-}
-
-fn seed_time() -> Option<()> {
+pub fn seed() -> Option<()> {
let n = SystemTime::now()
.duration_since(SystemTime::UNIX_EPOCH)
.ok()?;
-
*STATE.lock().unwrap() = n.as_nanos() as u64;
- return Some(());
-}
-pub fn seed() -> Option<()> {
- match seed_urandom() {
- Some(()) => return Some(()),
- None => (),
- }
- match seed_time() {
- Some(()) => return Some(()),
- None => (),
- }
- return None;
+ return Some(());
}
fn mix(s: &mut u64) {