CRC
Home implements a custom CRC-like algoritm, often used to represent paths as a signed 32-bit integer.
Usages
- Cached files: the name of the files in the game’s
CACHEdirectory is<prefix>_<hash>.<ext>, where<hash>is the CRC hash of the file’s full URL to the CDN. - Archive entries: archives only store the hash of the paths for the files they contain, relative to the archive’s root.
Implementation
Below is a Rust implementation of the algorithm:
// NOTE: hashes are always lowercase
pub fn hash(data: std::str::Chars) -> i32 {
let mut hash: i32 = 0;
for mut c in data {
if c == '\\' {
c = '/';
}
c = c.to_lowercase().next().unwrap();
hash = hash.overflowing_mul(0x25).0; // Decimal: 37
hash += c as i32;
}
hash
}Last updated on