QuickHash

From Stack Overflow
Jump to: navigation, search
unsigned int quickHash(const unsigned char* str, unsigned int len) {
   unsigned int b    = 378551;
   unsigned int a    = 63689;
   unsigned int hash = 0;
   unsigned int i    = 0;

   for(i = 0; i < len; str++, i++)
   {
      hash = hash*a+(*str);
      a = a*b;
   }

   return (hash & 0x7FFFFFFF);

}
Personal tools