pub fn compute_hash(input: &str) -> StringExpand description
Compute a 5-character base62 hash from an input string
Uses ahash with a fixed “Waddling” salt to ensure deterministic results across compilations and platforms. Returns an alphanumeric-only hash that is safe for all logging systems and provides 916M+ combinations.
§Algorithm
- Initialize ahash with fixed seeds (derived from “Waddling”)
- Hash the salt + input string
- Take the first 5 bytes of the 64-bit hash
- Convert to base62 (0-9, A-Z, a-z)
§Examples
use waddling_errors_hash::compute_hash;
let hash = compute_hash("E.AUTH.TOKEN.001");
assert_eq!(hash.len(), 5);
assert!(hash.chars().all(|c| c.is_ascii_alphanumeric()));§Determinism
The same input will always produce the same hash:
use waddling_errors_hash::compute_hash;
let hash1 = compute_hash("E.AUTH.TOKEN.001");
let hash2 = compute_hash("E.AUTH.TOKEN.001");
assert_eq!(hash1, hash2);