int i = klen; unsigned int hash = 0; char *s = key; while (i--) hash = hash * 33 + *s++; #### klen is the number of characters to be encoded. 12345678901234567890123456789012345678901234567 the string above has 47 chars and would be klen for example.