Skip to content
Jan Špaček edited this page Apr 12, 2016 · 1 revision

Spiral implements the cryptographic hash function SipHash-2-4. When a program starts, it generates a pseudo-random key that is used by the default hash functions.

  • default hashing functions are keyed by the global random key and are intended to be used with module std.hashmap.
    • (hash-int x) returns a hash for integer x.
    • (hash-str str) returns a hash for string str.
    • (hash-sym sym) returns a hash for symbol sym.
  • hashers can be used to generate hashes for arbitrary structures, possibly with custom key.
    • (hasher-new) creates a new hasher keyed with the global key.
    • (hasher-new-keyed k0 k1) creates a new hasher keyed with k0 and k1. Note that Spiral can only represent 31-bit keys!.
    • (hasher-finish! h) completes the hashing and returns the lowest 31 bits of the hash. The hasher cannot be reused.
    • (hasher-push-str! h str) feeds a string into the hasher.
    • (hasher-push-int! h x) feeds an integer to the hasher as a little endian 32 bit integer.
    • (hasher-push-sym! h sym) feeds a symbol into the hasher.