public static int getCrc_CRC16_X25(byte[] bytes) {
int i, j, lsb;
int h = 0xffff;
for (i = 0; i < bytes.length; i++) {
h ^= (bytes[i] & 0xff);
h &= 0xffff;
for (j = 0; j < 8; j++) {
lsb = h & 0x0001; //取 CRC 的移出位
h >>= 1;
if (lsb == 1) {
h ^= 0x8408;
h &= 0xffff;
}
}
}
h ^= 0xffff;
return h;
}
版权声明:本文为u012842328原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。