1.先要知道多项式是什么样子,以这个IEEE802.3标准CRC32多项式为例:x32+x26+x23+x22+x16+x12+x11+x10+x8+x7+x5+x4+x2+x+ 1 2.转换成一个值(这个值的命名我不知道啊) x32 则对应32bit = 1, x26 则对应26bit=1,得出一个值:(1<<32)|(1<<26)|(1<<23)|(1<<22)|...|(1<<1)|(1)=0x1...
unsigned int hash_CRC32_png(unsigned char *data, unsigned int length){ unsigned int hash = 0xffffffff; unsigned int i; for(i=0; i<length; i++){ hash = (hash >> 8) ^ crc32table[(hash & 0x0ff) ^ data[i]]; } return ~hash; } 初始值为输入数据的字节数。在我心中我把它当做哈希...
CRC32算法(查表法)代码 #include <windows.h>#include <stdio.h>void PrintCrcTable(){ //Poly = 0xedb88320 WinRAR Poly DWORD Val; for (DWORD i = 0; i < 256; i++) { Val = i; for (DWORD k = 0; k < 8; k++) { if (Val & 1) Val = 0xedb88320L ^ (Val >> 1); else ...
uint32_t crc32_compute(const uint32_t initial_value,const uint8_t * data,const uint32_t data_length) { uint32_t crc = initial_value; uint32_t idx; const uint32_t zero = 0U; const uint32_t modulo_256 = 0xffU; const uint32_t byte_shift = 8U; const uint32_t crc32_table[...
3.用这个值通过一定方法生成长度为256的码表,对于CRC32表内每个元素都为32bit. 4.用一定的方法查表得出CRC32值。 好了,可以贴代码了: /* * CRC校验算法,查表法 * <kerndev@foxmail.com> */ #include "crc.h" static unsigned long table[256]; ...
CRC32查表法 2013-09-29 18:32 −CRC参数模型: Name : "CRC-32" Width : 32 Poly : 04C11DB7 Init : FFFFFFFF RefIn : True RefOut : True XorOut : FFF... 孜求嵌道 0 17898 查表法计算CRC16校验值 2015-04-21 15:33 −CRC16是单片机程序中常用的一种校验算法。依据所采用多项式的不同,...
4.用一定的方法查表得出CRC32值。 好了,可以贴代码了: [cpp]view plaincopyprint? /* * CRC校验算法,查表法 * */ #include 'crc.h' staticunsignedlongtable[256]; //位逆转 staticunsignedlongbitrev(unsignedlonginput,intbw) { inti; unsignedlongvar; ...
/* // 生成上面的CRC32表 static void hash_makeCRC32table(unsigned int table[]){ unsigned int value; unsigned int i, j; for(i=0; i<256; i++){ value = i; for(j=0; j<8; j++){ if(value&1){ value = (value >> 1) ^ 0xedb88320; } else{ value = (value >> 1); } } ...