/*
* hash_16
* DESCRIPTION: Produces a 16-bit hash of the input given the length.
* Currently uses Bernstein-like hash; we may want to consider
* another hashing algorithm later if we need to.
* INPUTS: unsigned char* input - bytestring to be hashed
* int length - number of bytes to read from input
* OUTPUTS: 16-bit hash of the input
*/
uint16_t hash16(uint8_t* input, int length) {
uint16_t hash = 5381; // seed for Bernstein hash
int i;
// Hash over all bytes in input
for(i = 0; i < length; i++) {
hash = ((hash << 5) + hash) + *input++;
}
return hash;
}