#1 Followed the MagicOnion quickstart guide, borrowing code from the chat sample app to get something working
27 lines
616 B
C#
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);
|
|
}
|
|
}
|
|
}
|