#include <stdio.h>
#include <stdlib.h>
unsigned long chop_chop_hash(const char* string)
{
unsigned long block = 5381;
unsigned char* chops = (unsigned char*)(&block);
size_t state = 0;
while(*string)
{
chops[state] = chops[state++] ^ (*string++);
state = state == sizeof(unsigned long) ? 0 : state;
}
return block;
}
/*chop chop hash of 'aa' is 353285
* chop chop hash of 'aab' is 1728406533
* chop chop hash of 'foods' is 127575075349253
* chop chop hash of 'Hello World!' is 3487834674689494277
* chop chop hash of 'mt14 is the best team in splunk' is * 2544596569758132229
*
*/
int main(void) {
printf("chop chop hash of '%s' is %lu\n", "aa", chop_chop_hash("aa"));
printf("chop chop hash of '%s' is %lu\n", "aab", chop_chop_hash("aab"));
printf("chop chop hash of '%s' is %lu\n", "foods", chop_chop_hash("foods"));
printf("chop chop hash of '%s' is %lu\n", "Hello World!", chop_chop_hash("Hello World!"));
printf("chop chop hash of '%s' is %lu\n", "mt14 is the best team in splunk", chop_chop_hash("mt14 is the best team in splunk"));
return 0;
}