C# CRC 计算 校验
标签:int col style public 校验 turn color sea ram
///
/// CRC计算
///
/// 源数据
/// 开始位置
/// 长度
///
public static byte [] Crc(byte[] arr, UInt16 seat, UInt32 len)
{
UInt32 i;
UInt16 j, uwCrcReg = 0xFFFF;
for (i = seat; i )
{
uwCrcReg ^= arr[i];
for (j = 0; j 8; j++)
{
if ((uwCrcReg & 0x0001) != 0)
{
uwCrcReg = (UInt16)((UInt16)(uwCrcReg >> 1) ^ (UInt16)0xA001);
}
else
{
uwCrcReg = (UInt16)(uwCrcReg >> 1);
}
}
}
byte [] CRC=new byte[2];
CRC[0] = (byte)(uwCrcReg);
CRC[1] = (byte)(uwCrcReg >> 8);
return CRC;
}
C# CRC 计算 校验
标签:int col style public 校验 turn color sea ram
原文地址:https://www.cnblogs.com/xwcs/p/13359847.html
评论