compute_hash

Function compute_hash 

Source
pub fn compute_hash(input: &str) -> String
Expand 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

  1. Initialize ahash with fixed seeds (derived from “Waddling”)
  2. Hash the salt + input string
  3. Take the first 5 bytes of the 64-bit hash
  4. 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);