mirror of
https://github.com/Steffo99/better-tee.git
synced 2024-11-29 01:44:19 +00:00
18 lines
503 B
C#
18 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;
|
|
}
|
|
}
|
|
}
|
|
}
|