/// <summary>
/// 计算CRC16校验码 1.0
/// </summary>
/// <param name="bytes">字节数组</param>
/// <param name="len">校验的长度</param>
/// <returns>校验码</returns>
public static int GetCRC(byte[] bytes, int len)
{
int CRC = 0x0000ffff;
int POLYNOMIAL = 0x0000a001;
int i, j;
for (i = 0; i < len; i++)
{
CRC ^= ((int)bytes[i] & 0x000000ff);
for (j = 0; j < 8; j++)
{
if ((CRC & 0x00000001) != 0)
{
CRC >>= 1;
CRC ^= POLYNOMIAL;
}
else
{
CRC >>= 1;
}
}
}
return CRC;
}