File src/hash/hash-functions.c

Functions

compute_hash (state, key, keylen, vector) Call the correct hash function depending on what was used.
local hash_djb2 (key, len) These hash functions are all from the cmph sources, where they can be found in the xxx_hash.c files.
local hash_fnv (key, len) See http://www.isthe.com/chongo/tech/comp/fnv/.
local hash_jenkins (k, length, initval, vector) Calculate the hash value using the Jenkins algorithm.


Functions

compute_hash (state, key, keylen, vector)
Call the correct hash function depending on what was used.

Parameters

  • state:
  • key:
  • keylen:
  • vector: (optional) A memory area where to store the internal state of the hash function, i.e. three 32 bit words. Any one of them can be used as a hash value, preferably vector[2].
local hash_djb2 (key, len)
These hash functions are all from the cmph sources, where they can be found in the xxx_hash.c files. In version 0.8, only hash_jenkins remains. Note that cmph version has an xor operation instead of the addition (a change supposedly favored by Dan Bernstein, the author of this algorithm).

Parameters

  • key:
  • len:
local hash_fnv (key, len)
See http://www.isthe.com/chongo/tech/comp/fnv/. The algorithm included in cmph-0.6 is therefore "FNV-0", which is obsolete; it doesn't have a non-zero initialization for "hash".

Parameters

  • key:
  • len:
local hash_jenkins (k, length, initval, vector)
Calculate the hash value using the Jenkins algorithm.

Parameters

  • k: key string
  • length: length of the key
  • initval: previous hash, or an arbitrary value
  • vector: place to store the internal state variables a, b, c

Return value:

the hash value

Valid XHTML 1.0!