Why I like the djb2 hash

Because it can be memorized and works reasonably well:

    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;
    }

All one needs to remember is a single line and a number. For years SuperFastHash had been my first choice but the Non-Cryptographic Hash Function Zoo analysis changed this.

[via]

Leave a comment