I need a hasher for something I'm working on and put this SimpleHasher together.
It only XORs the current hash with the new content, which is probably not very resistant to collisions, but seems to work OK for what I need.
expect hasher 0 |> Hash.hash 12u8 |> Hash.complete == 12u64
expect hasher 0 |> Hash.hash (SomeTag 42) |> Hash.complete == 42u64
expect hasher 0 |> Hash.hash { a: 84, b: "x", c: Yellow "Submarine" } |> Hash.complete == 4976968789605u64
expect hasher 0 |> Hash.hash "SomeString" |> Hash.complete == 3681188331052135u64
If someone with a deeper appreciation for the mathematics improves on this, I'd be keen to use it :smiley:
You could steal the standard library impl, just fork that. It should be a nice hash, but depends on the exact goals
Oh neat. I hadn't noticed that before. Now I know what I'm looking at I can see it.
Might even be worth releasing as a wyhash package
Last updated: Jul 06 2025 at 12:14 UTC