标签:ad ef amp new ui br return c# 函数
private byte[] CRC(byte[] x, int len) //CRC校验函数
{
byte[] temdata = new byte[2];
UInt16 crc = 0;
byte da;
int i = 0;
UInt16[] yu = { 0x0000,0x1021,0x2042,0x3063,0x4084,0x50a5,0x60c6,0x70e7,
0x8108,0x9129,0xa14a,0xb16b,0xc18c,0xd1ad,0xe1ce,0xf1ef };
while (len-- != 0)
{
da = (byte)(((byte)(crc / 256)) / 16);
crc <<= 4;
crc ^= yu[da ^ x[i] / 16];
da = (byte)(((byte)(crc / 256)) / 16);
crc <<= 4;
crc ^= yu[da ^ x[i] & 0x0f];
i++;
}
temdata[0] = (byte)(crc & 0xFF);
temdata[1] = (byte)(crc >> 8);
return temdata;
}
CRC-16/XMODE X16+X12+X5+1 C#环境下实现
标签:ad ef amp new ui br return c# 函数
原文地址:http://www.cnblogs.com/felixzh/p/4143448.html