Function: fnvHashWithOptions()
fnvHashWithOptions(
options?, …values):string
Configurable counterpart to fnvHash.
Options:
length(default6): number of base-32 chars to return. Capped at 7 - the underlying digest is 32 bits, which base-32-encodes to at most 7 chars. Output is left-padded with the alphabet’s zero character so short digests still hit the requested width.alphabet(default Crockford-style"0123456789abcdefghjkmnpqrstvwxyz"): 32 distinct characters used to encode the digest. Throws when not exactly 32 unique chars.digest(default0x811c9dc5, the FNV-1a offset basis): the seed the running digest starts from. Useful for namespacing so otherwise-identical inputs hashed under different namespaces never collide, and for chaining hashes across pipeline stages.
The hash is not stable across changes to the alphabet or length -
those tune the output, not the digest input.
Parameters
Section titled “Parameters”options?
Section titled “options?”alphabet?
Section titled “alphabet?”string
digest?
Section titled “digest?”number
length?
Section titled “length?”number
values
Section titled “values”…unknown[]
Returns
Section titled “Returns”string
Example
Section titled “Example”fnvHashWithOptions({ length: 4 }, "user@example.com"); // 4 charsfnvHashWithOptions({ digest: nsHash }, key) !== fnvHash(key); // namespaced