No description
Find a file
Emery Hemingway c3115ebb6c Add README
2018-11-26 14:24:15 +01:00
src Add README 2018-11-26 14:24:15 +01:00
tests Initial commit 2018-09-23 22:39:25 +02:00
.gitignore Initial commit 2018-09-23 22:39:25 +02:00
README.md Add README 2018-11-26 14:24:15 +01:00
siphash.nimble Add README 2018-11-26 14:24:15 +01:00

SipHash

SipHash is an addrotatexor (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