PdfSharp.Fonts.TrueType.TrueTypeFontTable.CalcChecksum C# (CSharp) Method

CalcChecksum() public static method

Calculates the checksum of a table represented by its bytes.
public static CalcChecksum ( byte bytes ) : uint
bytes byte
return uint
    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;
    }
  }