crc.h
上传用户:xs588588
上传日期:2021-03-30
资源大小:242k
文件大小:2k
- #define CRC_TABLE_SIZE 256
- #define CRC16_CHECK 0xFEE8
- #define CRC16R_CHECK 0xBB3D
- #define CRC32_CHECK 0xFC891918
- #define CRC32R_CHECK 0xCBF43926
- // CRC-16: x16 + x15 + x2 + 1
- #define CRC16_POLY 0x8005
- #define CRC16_INIT_REM 0x0
- #define CRC16_FINAL_XOR 0x0
- #define CRC16R_POLY 0xA001
- #define CRC16R_INIT_REM 0x0
- #define CRC16R_FINAL_XOR 0x0
- // CRC-CCITT: x16 + x12 + x5 + 1
- #define CRC16_POLY_CCITT 0x1021
- #define CRC16_INIT_REM_CCITT 0x0
- #define CRC16_FINAL_XOR_CCITT 0x0
- // CRC-32: x32 + ... + 1
- #define CRC32_POLY 0x04C11DB7
- #define CRC32_INIT_REM 0xFFFFFFFF
- #define CRC32_FINAL_XOR 0xFFFFFFFF
- #define CRC32R_POLY 0xEDB88320
- #define CRC32R_INIT_REM 0xFFFFFFFF
- #define CRC32R_FINAL_XOR 0xFFFFFFFF
- unsigned short crc16Bitwise(unsigned short crc, unsigned short poly,
- unsigned char *pmsg, unsigned int msg_size);
- unsigned short crc16Bitwise2(unsigned short crc, unsigned short poly,
- unsigned char *pmsg, unsigned int msg_size);
- unsigned long crc32Bitwise(unsigned long crc, unsigned long poly,
- unsigned char *pmsg, unsigned int msg_size);
- unsigned long crc32Bitwise2(unsigned long crc, unsigned long poly,
- unsigned char *pmsg, unsigned int msg_size);
- unsigned short crc16TableMethod(unsigned short crc, unsigned short *table,
- unsigned char *pbuffer, unsigned int length);
- unsigned short crc16rTableMethod(unsigned short crc, unsigned short *table,
- unsigned char *pbuffer, unsigned int length);
- unsigned long crc32TableMethod(unsigned long crc, unsigned long *table,
- unsigned char *pbuffer, unsigned int length);
- unsigned long crc32rTableMethod(unsigned long crc, unsigned long *table,
- unsigned char *pbuffer, unsigned int length);
- void crc16BuildTable(unsigned short *ptable, unsigned short poly);
- void crc32BuildTable(unsigned long *ptable, unsigned long poly);
- unsigned long bitReflect(unsigned long data, unsigned int width);