文件名称:CCITT CRC32算法伪代码
文件大小:4KB
文件格式:C
更新时间:2013-04-21 11:51:25
CRC32 算法 C语言代码
static u32_t crc_32_tab[] = { /* CRC polynomial 0xedb88320 */ 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, 0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, ............ u32_t CreateCRC32(u8_t *databuf,u32_t len) { u32_t oldcrc32,crc32,oldcrc; u16_t charcnt; u8_t c; u32_t t; oldcrc32 = 0x00000000; charcnt = 0; while(len --){ t = (oldcrc32>> 24)&0xFF; oldcrc = crc_32_tab[t]; c = databuf[charcnt]; oldcrc32 = (oldcrc32 << 8)|c; oldcrc32 = oldcrc32 ^ oldcrc; charcnt ++; } crc32 = oldcrc32; return crc32; }