1use std::time::{SystemTime, UNIX_EPOCH};
2
3fn current_time() -> u128 {
4 let now = SystemTime::now();
5 let nanos = now.duration_since(UNIX_EPOCH)
6 .expect("time went backwards")
7 .as_nanos();
8 return nanos;
9}
10
11fn scramble(mut n: u128) -> u128 {
12 n ^= 0xDEADC0DD;
13 n <<= 0xF;
14 n ^= 0xCAFEBEEF;
15 n ^= 0xBEEF;
16 n |= 0xCAFE;
17 n >>= 0xF;
18 n ^= 0xBEEFAEA7;
19 n <<= 20;
20 n ^= 0xFDFEDDDD;
21 n <<= 20;
22 n ^= 0xB4DD1E;
23 n |= 0xC0DE;
24 n
25}
26
27pub fn get_uuid() -> u128 {
28 let mut random = current_time();
29 random = scramble(random);
30
31 return random;
32}