Public Class CheckSum
    ''' <summary>
    ''' 获取数据包的和校验
    ''' </summary>
    ''' <param name="packet">数据包的内容</param>
    ''' <returns></returns>
    Public Shared Function GetPacketCheck(packet() As Byte) As Byte
        Dim result As Integer

        '当packet的相加综合超过INT_MAX则会异常
        For Each b As Byte In packet
            result += b
        Next

        Return CByte(&HFF - (result And &HFF))
    End Function

End Class
