crc16.h
来自「isdn的完整解决方案。非常强大。不过是国际标准而非国标。」· C头文件 代码 · 共 62 行
H
62 行
// Crc16.h#ifndef USHORT#define USHORT unsigned short#endif#ifndef BYTE#define BYTE unsigned char#endif#ifndef TRUE#define TRUE (1)#endif#ifndef FALSE#define FALSE (0)#endif#define BOOL int/** This class provides functions for computing 16-bit CRC values.* It implements both a slow bit-at-a-time method and a table-driven* method. The simple method was implemented as a way of verifying* that the optimized table-method works. ** POPULAR POLYNOMIALS** @li CCITT: x^16 + x^12 + x^5 + x^0 (set m_Polynomial to 0x1021)* @li CRC-16: x^16 + x^15 + x^2 + x^0 (set m_Polynomial to 0x8005)*** REFLECTED INPUT/CRC** Reflected input and reflected CRC is common with serial interfaces.* This is because the least-significant-bit is typically transmitted * first with serial interfaces.*/class CCrc16{public: CCrc16(); USHORT ReverseBits( USHORT x ); BYTE ReverseBits( BYTE b ); void SimpleNextByte( BYTE b ); USHORT SimpleComputeBlock( BYTE* data, int length ); USHORT SimpleGetCrc(); USHORT CreateTableEntry( int index ); void CreateTable(); USHORT ComputeCrcUsingTable( BYTE* data, int length ); USHORT m_Crc; USHORT m_ResetValue; USHORT m_Polynomial; BOOL m_Reflect; BOOL m_ReflectCrc; USHORT m_CrcXorOutput; USHORT m_Table[256];};
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?