Aetheria/Assets/Scripts/MagicOnion/Utils/FNV1A32.cs
hyperion51 a0c8dbee72 Initial Client/Server Communication
#1
Followed the MagicOnion quickstart guide, borrowing code from the chat sample app to get something working
2020-02-26 17:48:40 +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);
}
}
}