namespace Pathfinding.Util {
/// Calculates checksums of byte arrays
internal class Checksum {
/// Calculate checksum for the byte array.
/// Byte array to calculate checksum for. May be null.
/// Initial hash value. Default is 0. Can be used to chain checksums together.
public static uint GetChecksum (byte[] arr, uint hash = 0) {
// Sort of implements the Fowler–Noll–Vo hash function
const int prime = 16777619;
hash ^= 2166136261U;
if (arr == null) return hash - 1;
for (int i = 0; i < arr.Length; i++)
hash = (hash ^ arr[i]) * prime;
return hash;
}
}
}