java方法:
public short Caculate(byte[] msg)
{
short crc = (short) 0xFFFF;
int i, j;
boolean c15, bit;
for (i = 0; i < msg.length; i++) {
for (j = 0; j < 8; j++) {
c15 = ((crc >> 15 & 1) == 1);
bit = ((msg[i] >> (7 - j) & 1) == 1);
crc <<= 1;
if (c15 ^ bit) crc ^= 0x1021;
}
}
return crc;
}
改后的php??