Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- hash function for string
- unsigned long
- hash(unsigned char *str)
- {
- unsigned long hash = 5381;
- int c;
- while (c = *str++)
- hash = ((hash << 5) + hash) + c; /* hash * 33 + c */
- return hash;
- }
- int hash(char const *input) {
- int result = 0x55555555;
- while (*input) {
- result ^= *input++;
- result = rol(result, 5);
- }
- }
- uint32_t jenkins_one_at_a_time_hash(char *key, size_t len)
- {
- uint32_t hash, i;
- for(hash = i = 0; i < len; ++i)
- {
- hash += key[i];
- hash += (hash << 10);
- hash ^= (hash >> 6);
- }
- hash += (hash << 3);
- hash ^= (hash >> 11);
- hash += (hash << 15);
- return hash;
- }
Add Comment
Please, Sign In to add comment