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 nanos
9}
10
11fn scramble(mut n: u128) -> u128 {
12 n ^= 0xDEADC0DD;
13 n <<= 0xF;
14 n |= 0xC0DE;
15 n ^= 0xBAFEBEEF;
16 n ^= 0xCFED;
17 n |= 0xADEF;
18 n >>= 0xF;
19 n ^= 0xBEEFAEA7;
20 n = n.rotate_left(24);
21 n <<= 20;
22 n ^= 0xFDFEDDDD;
23 n <<= 20;
24 n = n.wrapping_mul(0x5F23FF248FD8FF0D);
25 n ^= 0xB4DD1E;
26 n
27}
28
29pub fn get_uuid() -> u128 {
30 let mut random = current_time();
31 random = scramble(random);
32 random
33}