#include <STDIO.H>
#include <MATH.H>
// POLY
//注意:因最高位一定为“1”,故略去
#define cnCRC_64_H 0x42F0E1EB
#define cnCRC_64_L 0xA9EA3693
//CRC-64-ECMA-182 x64 + x62 + x57 + x55 + x54 + x53 + x52 + x47 + x46 + x45 +
//x40 + x39 + x38 + x37 + x35 + x33 + x32 + x31 + x29 + x27 + x24 + x23 + x22
//+ x21 + x19 + x17 + x13 + x12 + x10 + x9 + x7 + x4 + x + 1
//(as described in ECMA-182 p.63) or 0xC96C5795D7870F42 (0x92D8AF2BAF0E1E85)
unsigned long TableCRCHigh[256]; // CRC ±í for 64
unsigned long TableCRCLow[256]; // CRC ±í for 64
void BuildTable64(); //建立CRC表
unsigned long* CRC_64( unsigned char * aData, unsigned long aSize ); //生成CRC
//unsigned char test[11] = {0x01,0x02,0x03,0xf8,0x05,0x60,0x9e,0xce,0x1e,0xcb,0xf3};
unsigned char test[5] = {'A','B','C','D','E'};
void main()
{
unsigned int i;
unsigned long* crc64; //CRC的结果
BuildTable64(); //creat table
for (i=0;i<256;i++)
{
printf("%x,%x\n", TableCRCHigh[i],TableCRCLow[i]);
}
crc64 = CRC_64(test,11); //creat CRC value
printf("The CRC is:%x,%x\n", *crc64,*(crc64+1));
}
|