日期:2014-05-20 浏览次数:20733 次
public class Test01 {
public static void main(String[] args) {
int crc = CRC16(new byte[] { 0x01, 0x02, 0x03, 0x04, 0x03, 0x02 }, 6);
System.out.println(Integer.toHexString(crc));
}
static int CRC16(byte[] buffer, int len) {
int index = 0;
int crc = 0;
while (len-- > 0) {
crc = (crc >> 8)
------解决方案--------------------
(crc << 8);
crc ^= buffer[index++];
crc ^= (crc & 0xff) >> 4;
crc ^= (crc << 8) << 4;
crc ^= ((crc & 0xff) << 4) << 1;
crc &= 0xFFFF;
}
return crc;
}
}