C# CRC校验,通过11 01 08 98 12 01 03 35 30 75 10 1B 32 01 00 01数组计算出59 E6怎么计算

有c语言源码
2025-04-14 02:52:24
推荐回答(1个)
回答1:

原封不动的抄下来就行了......

static readonly ushort[] crctab16 = new ushort[] {
  //复制粘贴
};

ushort GetCrc16(byte[] data, int offset, int length) {
  ushort fcs = 0xffff;
  while (length>0) {
    fcs = (ushort)((fcs>>8)^crcab16[(fcs^pdata[offset+offset]) & 0xff]);
    length--;
    offset++;
  }
  return (ushort)(~fcs);
}