The default Fief.Hasher: :erlang.phash2(key, 4_294_967_296) over
binaries only. A non-binary key raises ArgumentError (prefixed with the
calling surface's name by Fief.Hasher.vnode!/4), telling you to either
encode your keys to binaries yourself or configure a custom :hasher module —
the same forced-explicit-canonicalization the old key_encoder contract
provided.
Why phash2 (Decision, implementation.md §7)
Current OTP documentation states, verbatim: "The hash value for the same
Erlang term is guaranteed to be the same regardless of machine architecture
and ERTS version." That is exactly the cross-node, cross-release stability the
immutable key→vnode mapping requires (design §9). The older rationale that
rejected :erlang.phash2 as non-contractual predates this guarantee.
What this gives up, relative to the prior SHA-256 hash:
- The placement function is no longer computable outside a BEAM (SHA-256 was reproducible from any language). Tooling that wants to predict a key's vnode must run on the BEAM.
:cryptowas the library's only crypto dependency; it is now dropped.
A hasher module is fingerprinted by identity, so this module is the pinned algorithm version — a future algorithm is a new module.
The pinned mapping (this value may never change):
iex> Fief.Hasher.Default.hash_key("user:42")
677879827