Answer the question
In order to leave comments, you need to log in
Choosing a non-cryptographic hashing algorithm?
For one self-written load balancer, you must select an algorithm (not cryptographic) for calculating checksums. The input data (string keys) is always exactly larger than 32 bytes.
I would love to hear the opinion of developers with a deep understanding of the topic. Which of the following algorithms would you recommend or caution against using?
What I managed to find myself:
Answer the question
In order to leave comments, you need to log in
If you do not bother too much, then in the book "Programming Practice" by Kernighan and Pike there is a fairly simple algorithm:
enum { MULTIPLIER = 31 };
/* hash: calculate
the hash function of the string */
unsigned int hash(char *str)
{
unsigned int h;
unsigned char *p;
h = 0;
for (p = (unsigned char *)
str; *p != '\0'; p++)
h = MULTIPLIER * h +
*p; return h % NHASH; }
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question