mirror of
https://github.com/Steffo99/better-tee.git
synced 2024-11-25 16:34:17 +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;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|