removed an unnessessary genreate button
This commit is contained in:
+21
@@ -0,0 +1,21 @@
|
||||
use std::time::{SystemTime, UNIX_EPOCH};
|
||||
|
||||
pub fn random_seed() -> u64 {
|
||||
let nanos = SystemTime::now()
|
||||
.duration_since(UNIX_EPOCH)
|
||||
.map(|d| d.as_nanos() as u64)
|
||||
.unwrap_or(0);
|
||||
let pid = std::process::id() as u64;
|
||||
mix64(nanos ^ pid.rotate_left(17))
|
||||
}
|
||||
|
||||
pub fn derive_seed(master_seed: u64, stream_id: u64) -> u64 {
|
||||
mix64(master_seed ^ stream_id.wrapping_mul(0x9E37_79B9_7F4A_7C15))
|
||||
}
|
||||
|
||||
fn mix64(mut x: u64) -> u64 {
|
||||
x = x.wrapping_add(0x9E37_79B9_7F4A_7C15);
|
||||
x = (x ^ (x >> 30)).wrapping_mul(0xBF58_476D_1CE4_E5B9);
|
||||
x = (x ^ (x >> 27)).wrapping_mul(0x94D0_49BB_1331_11EB);
|
||||
x ^ (x >> 31)
|
||||
}
|
||||
Reference in New Issue
Block a user