Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

djb2 hash function c explained

// Djb2 hash function
unsigned long hash(char *str) 
{

        unsigned long hash = 5381;
        int c;
        while ((c = *str++))
            hash = ((hash << 5) + hash) + c; /* hash * 33 + c */
        return hash % NUM_BUCKETS;

}
Source by gist.github.com #
 
PREVIOUS NEXT
Tagged: #hash #function #explained
ADD COMMENT
Topic
Name
8+6 =