public int GetHashValue(string strInput)
{
int result = 0 ;
uint hash = 0;
int i = 0;
int sum = 0;
for (i = 0; i < (strInput.Length - 3); i = i + 4)
{
int a = strInput[i];
a = (a << 8) + strInput[i + 1];
a = (a << 8) + strInput[i + 2];
a = (a << 8) + strInput[i + 3];
sum += a;
}
for (; i < strInput.Length; i ++ )
{
int a = strInput[i];
sum += a;
}
result = sum % 65535;
return result;
{
int result = 0 ;
uint hash = 0;
int i = 0;
int sum = 0;
for (i = 0; i < (strInput.Length - 3); i = i + 4)
{
int a = strInput[i];
a = (a << 8) + strInput[i + 1];
a = (a << 8) + strInput[i + 2];
a = (a << 8) + strInput[i + 3];
sum += a;
}
for (; i < strInput.Length; i ++ )
{
int a = strInput[i];
sum += a;
}
result = sum % 65535;
return result;
}
其中:65535是可以调整的