1 2 3 4 5 6 7 8 9 10 11 12
pub fn djb2(input: &str) -> String { let mut hash: i64 = 0; for c in input.chars() { hash = ((hash << 5).wrapping_sub(hash)).wrapping_add(c as i64); } // Convert to unsigned 32-bit integer hash &= 0xFFFFFFFF; hash.to_string() }