/// <summary>
/// 根据传入字符串获取自定义hash值
/// </summary>
/// <returns></returns>
///
public static int GetHash(string str)
{
int hash = 0;
byte[] strByte = System.Text.Encoding.Default.GetBytes(str);
foreach (byte b in strByte)
{
hash = hash * 31 + b;
}
return hash;
}
public static int GetHash1(string str)
{
uint h = 0;
var arr = str.ToCharArray();
for (int i = 0; i < arr.Length; i++)
{
h = h * 31 + (uint)arr[i];
}
int a = (int)h;
return (int)h;
}