public static uint CalcChecksum(byte[] bytes)
{
Debug.Assert((bytes.Length & 3) == 0);
// Cannot use Buffer.BlockCopy because 32-bit values are Big-endian
uint byte3, byte2, byte1, byte0;
byte3 = byte2 = byte1 = byte0 = 0;
int length = bytes.Length;
for (int idx = 0; idx < length;)
{
byte3 += bytes[idx++];
byte2 += bytes[idx++];
byte1 += bytes[idx++];
byte0 += bytes[idx++];
}
return (byte3 << 24) + (byte2 << 16) + (byte1 << 8) + byte0;
}
}