Skip to main contentModule hash
Source - HASH_BASE
- Fibonacci hashing constant for good bit distribution.
- base_pow
- Compute HASH_BASE^n using wrapping multiplication.
Call once per format group to obtain the
window_power argument for roll(). - hash_token
- Hash a token with optional case folding.
- hash_window
- Compute the initial polynomial hash of a window of token hashes.
hash = h[0]*BASE^(n-1) + h[1]*BASE^(n-2) + … + h[n-1]*BASE^0
Uses wrapping arithmetic throughout.
- roll
- Roll the hash one position: remove
outgoing (the token leaving the window),
add incoming (the token entering the window). - token_hash
- Compute a deterministic hash for a single token given its kind byte and value string.
Uses xxh3_64 XORed with kind cast to u64.