small-uuid 0.2.2

cryptographically insecure pseudo-random uuid generator (custom)
Documentation
use std::time::{SystemTime, UNIX_EPOCH};

fn current_time() -> u128 {
    let now = SystemTime::now();
    let nanos = now.duration_since(UNIX_EPOCH)
        .expect("time went backwards")
        .as_nanos();
    nanos
}

fn scramble(mut n: u128) -> u128 {
    n ^= 0xDEADC0DD;
    n <<= 0xF;
    n |= 0xC0DE;
    n = n.rotate_left(43);
    n ^= 0xBAFEBEEF;
    n = n.wrapping_add(0xDFDFDFDFDFDFDFDF);
    n ^= 0xCFED;
    n |= 0xADEF;
    n = n.rotate_right(30);
    n >>= 0xF;
    n = n.wrapping_mul(0xD32B85533B2D22BD);
    n ^= 0xBEEFAEA7;
    n = n.rotate_left(24);
    n <<= 20;
    n ^= 0xFDFEDDDD;
    n <<= 20;
    n = n.wrapping_mul(0x5F23FF248FD8FF0D);
    n
}

pub fn get_uuid() -> u128 {
    let mut random = current_time();
    random = scramble(random);
    random
}