/* * strhash.c * * Created on: 21.10.2017 * Author: julian */ #include "strhash.h" // use rule: // hash(i) = hash(i - 1) * 33 ^ str[i] // see: http://www.cse.yorku.ca/~oz/hash.html strhash_t hash_add(strhash_t hash, char c) { return hash * 33 ^ c; } strhash_t hash_str(const char * str) { strhash_t hash = 0; while(*str) { hash = hash_add(hash, *str); str++; } return hash; }