Aetheria/Assets/Scripts/NIH/MagicOnion/Utils/FNV1A32.cs
hyperion51 c58ba0b1da Copy Aetheria Code
Added a bunch of code from the old Aetheria project
2020-02-27 18:51:07 +00:00

27 lines
616 B
C#

using System.Text;
namespace MagicOnion.Utils
{
public static class FNV1A32
{
public static int GetHashCode(string str)
{
return GetHashCode(Encoding.UTF8.GetBytes(str));
}
public static int GetHashCode(byte[] obj)
{
uint hash = 0;
if (obj != null)
{
hash = 2166136261;
for (int i = 0; i < obj.Length; i++)
{
hash = unchecked((obj[i] ^ hash) * 16777619);
}
}
return unchecked((int)hash);
}
}
}