crc16校验:
原c代码:
typedef unsigned char uint8_t;
typedef unsigned short uint16_t;
typedef unsigned int uint32_t;
uint16_t CRC16Caculate(uint8_t *AP, uint16_t LEN, uint16_t CRC16_Type)
{
uint16_t CRC16;
uint16_t i;
uint8_t CRC_H4;
uint16_t const CRCTable[16] ={0x0000,0x1021,0x2042,0x3063,0x4084,0x50A5,0x60C6,0x70E7,
0x8108,0x9129,0xA14A,0xB16B,0xC18C,0xD1AD,0xE1CE,0xF1EF};
CRC16= 0xFFFF - CRC16_Type;
for (i = 0; i <LEN; i++)
{
CRC_H4 = (uint8_t)(CRC16 >> 12);
CRC16 = CRC16 << 4;
CRC16 = CRC16 ^ CRCTable[CRC_H4 ^ (*AP >> 4)];
CRC_H4 = (uint8_t)(CRC16 >> 12);
CRC16 = CRC16 << 4;
CRC16 = CRC16 ^ CRCTable[CRC_H4 ^ (*AP & 0x0F)];
AP++;
}
return CRC16;
}
java代码:
public static char cr