small-uuid 0.2.4

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(0xDFDFDFDFDFDFDFDB);
    n ^= 0xCFED;
    n ^= n << 0x33;
    n |= 0xADEF;
    n = n.rotate_right(30);
    n >>= 0xF;
    n = n.wrapping_mul(0xD32B85533B2D22BE);
    n ^= 0xBEEFAEA7;
    n = n.rotate_left(24);
    n <<= 20;
    n ^= 0xFDFEDDDD;
    n <<= 20;
    n = n.wrapping_mul(0x5F23FF248FD8FF09);
    n ^= n >> 0x2F;
    n
}

pub fn get_uuid(i: u128) -> u128 {
    let mut random = current_time();
    for _ in 1..i {
        random = scramble(random);
    }

    random
}