示例#1
0
文件: crc.go 项目: desertbit/ants
func (c *crc16Validator) Checksum(data []byte) (rawCRC []byte) {
	// Calculate the CRC checksum of data.
	crc := crc16.Checksum(data, c.table)

	// Transform to a byte slice.
	rawCRC = make([]byte, 2)
	binary.LittleEndian.PutUint16(rawCRC, crc)

	return rawCRC
}
示例#2
0
文件: crc.go 项目: desertbit/ants
func (c *crc16Validator) Validate(data []byte, rawCRC []byte) bool {
	// Convert the raw CRC byte slice.
	origCRC := binary.LittleEndian.Uint16(rawCRC)

	// Calculate the CRC checksum of data.
	crc := crc16.Checksum(data, c.table)

	// Compare the checksums.
	return crc == origCRC
}