mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 19:10:32 +00:00
19 lines
503 B
C#
19 lines
503 B
C#
namespace Mirror
|
|
{
|
|
public static class StringHash
|
|
{
|
|
// string.GetHashCode is not guaranteed to be the same on all machines, but
|
|
// we need one that is the same on all machines. simple and stupid:
|
|
public static int GetStableHashCode(this string text)
|
|
{
|
|
unchecked
|
|
{
|
|
int hash = 23;
|
|
foreach (char c in text)
|
|
hash = hash * 31 + c;
|
|
return hash;
|
|
}
|
|
}
|
|
}
|
|
}
|