mirror of
https://git.sr.ht/~ehmry/nim_siphash
synced 2026-01-02 17:54:39 +00:00
No description
| src | ||
| tests | ||
| .gitignore | ||
| README.md | ||
| siphash.nimble | ||
SipHash
SipHash is an add–rotate–xor (ARX) based family of pseudorandom functions. It may be used to implement hash tables with resistence to hash flooding.
See: https://en.wikipedia.org/wiki/SipHash
Usage
import hashes
proc hash(s: string): Hash =
var key: siphash.Key
# this is a keyed hash function, use a zero key
let b: array[8, byte] = sipHash(toOpenArrayByte(s, s.low, s.high), key)
# the hash fuction operates over byte arrays
result = cast[Hash](b)
# casting or converting is up to you