標(biāo)題:
CRC32非查表范例,驗(yàn)證可用
[打印本頁]
作者:
again00txhj
時(shí)間:
2021-6-18 17:29
標(biāo)題:
CRC32非查表范例,驗(yàn)證可用
//Polynomial representations
//
//Normal :0x04C11DB7
//Reversed :0xEDB88320
//Reversed reciprocal :0x82608EDB
unsigned long CRC_32;
unsigned long crc32_in_c(unsigned char *p, unsigned char len)
{
unsigned char i,j;
unsigned long crc = 0xffffffff;
for(j=0;j<len;j++)
{
crc = crc ^ *p++;
for (i = 0;i<8;i++)
{
crc = (crc >> 1) ^ (0xedb88320 & -(crc & 1));
}
}
return ~crc;
}
//================================================
void main()
{
p_data[0]=0x33;
p_data[1]=0x34;
p_data[2]=0x35;
CRC_32= crc32_in_c((unsigned char *)&p_data[0], 3);
}
復(fù)制代碼
歡迎光臨 (http://www.torrancerestoration.com/bbs/)
Powered by Discuz! X3.1