siphash

SipHash, a pseudorandom function optimized for short messages.

Pure Nim score 30/100 · tests present · docs generated

Summary

Latest Version Unknown
License GPLv3
CI Status Passing
Downloads 0
Last Indexed 2026-07-21 05:24

Tags

Installation

nimble install siphash
choosenim install siphash
git clone https://git.sr.ht/~ehmry/nim_siphash

OS Compatibility

Platform Linux macOS Windows FreeBSD OpenBSD NetBSD Android iOS WASM Embedded
siphash - - - - - - -

Source

Repository https://git.sr.ht/~ehmry/nim_siphash
Homepage https://git.sr.ht/~ehmry/nim_siphash
Documentation View Documentation
Registry Source nimble_official

README

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