team04_server/log/
uuid_human_hash.rs1use uuid::Uuid;
6
7pub const WORDS1: [&'static str; 32] = [
8 "add", "and", "any", "ask", "bad", "big", "buy", "can", "cat", "cow", "cut", "dig", "dim",
9 "dry", "eat", "far", "fit", "fly", "fun", "has", "hex", "its", "lit", "mad", "new", "oak",
10 "odd", "one", "red", "sad", "shy", "wet",
11];
12pub const WORDS2: [&'static str; 32] = [
13 "ace", "aim", "air", "arm", "ash", "axe", "bag", "bat", "bit", "box", "car", "bug", "day",
14 "egg", "elk", "fan", "fox", "ham", "ice", "ink", "ivy", "inc", "jam", "jar", "jet", "key",
15 "kit", "owl", "pen", "sky", "spy", "van",
16];
17
18pub fn uuid_human_hash(uuid: &Uuid) -> String {
22 let bytes = uuid.as_bytes();
23 let mut sum: u16 = 0;
24 for i in 0..bytes.len() {
25 sum += bytes[i] as u16;
26 }
27 format!(
28 "{}-{}",
29 WORDS1[((sum >> 5) & (0b11111)) as usize],
30 WORDS2[(sum & (0b11111)) as usize]
31 )
32}