第三方库
"github.com/sigurn/crc16"
//这里使用MODBUS
table := crc16.MakeTable(crc16.CRC16_MODBUS)
crc := crc16.Checksum([]byte("Hello world!"), table)
c := fmt.Sprintf("%X", crc)
fmt.Println("CRC16==",c)
fmt.Println("CRC16_MODBUS:", crc)
using the standard library hash.Hash interface
h := crc16.New(table)
h.Write([]byte("Hello world!"))
fmt.Printf("CRC16_MODBUS: %X\n", h.Sum16())//16进制的格式打印
本文介绍了如何使用GitHub上的第三方库`github.com/sigurn/crc16`和标准库进行CRC16 MODBUS校验,通过实例展示了两种方法计算'Helloworld!'字符串的CRC16值,并对比了它们的实现细节。

565

被折叠的 条评论
为什么被折叠?



