azalea_auth/
offline.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use md5::{Digest, Md5};
use uuid::Uuid;

pub fn generate_uuid(username: &str) -> Uuid {
    uuid::Builder::from_md5_bytes(hash(format!("OfflinePlayer:{username}").as_bytes())).into_uuid()
}

fn hash(data: &[u8]) -> [u8; 16] {
    let mut hasher = Md5::new();

    hasher.update(data);

    let mut bytes = [0; 16];
    bytes.copy_from_slice(&hasher.finalize()[..16]);

    bytes
}