#include static unsigned char rand8[] = { 41, 35,190,132,225,108,214,174, 82,144, 73,241,187,233,235,179, 166,219, 60,135, 12, 62,153, 36, 94, 13, 28, 6,183, 71,222, 18, 77,200, 67,139, 31, 3, 90,125, 9, 56, 37, 93,212,203,252,150, 245, 69, 59, 19,137, 10, 50, 32, 154, 80,238, 64,120, 54,253,246, 158,220,173, 79, 20,242, 68,102, 208,107,196, 48,161, 34,145,157, 218,176,202, 2,185,114, 44,128, 126,197,213,178,234,201,204, 83, 191,103, 45,142,131,239, 87, 97, 255,105,143,205,209, 30,156, 22, 230, 29,240, 74,119,215,232, 57, 51,116,244,159,164, 89, 53,207, 211, 72,117,217, 42,229,192,247, 43,129, 14, 95, 0,141,123, 5, 21, 7,130, 24,112,146,100, 84, 206,177,133,248, 70,106, 4,115, 47,104,118,250, 17,136,121,254, 216, 40, 11, 96, 61,151, 39,138, 194, 8,165,193,140,169,149,155, 168,167,134,181,231, 85, 78,113, 226,180,101,122, 99, 38,223,109, 98,224, 52, 63,227, 65, 15, 27, 243,160,127,170, 91,184, 58, 16, 76,236, 49, 66,124,228, 33,147, 175,111, 1, 23, 86,198,249, 55, 189,110, 92,195,163,152,199,182, 81, 25, 46,188,148, 75, 88,210, 172, 26,162,237,251,221,186,171}; int WINAPI DllMain ( HANDLE hModule, HINSTANCE hInstance, DWORD ul_reason_for_call, LPVOID lpReserved) { return TRUE; } __declspec (dllexport) int vhash(char *str, int n) { if (n <= 256) { unsigned char h = 0; while (*str) h = rand8[h ^ *str++]; return h % n; } else { int h; unsigned char h1, h2; if (*str == 0) return 0; h1 = *str; h2 = *str + 1; str++; while (*str) { h1 = rand8[h1 ^ *str]; h2 = rand8[h2 ^ *str]; str++; } /* h is in range 0..65535 */ h = ((int)h1 << 8)|(int)h2; /* use division method to scale */ return h % n; } }