8000 GitHub - halloweeks/CRC-32: A C language implementation of the CRC-32 algorithm using the polynomial 0xEDB88320. Includes a pre-computed lookup table for efficient checksum computation.
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

A C language implementation of the CRC-32 algorithm using the polynomial 0xEDB88320. Includes a pre-computed lookup table for efficient checksum computation.

Notifications You must be signed in to change notification settings

halloweeks/CRC-32

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 

Repository files navigation

CRC-32

A C language implementation of the CRC-32 algorithm using the polynomial 0xEDB88320. Includes a pre-computed lookup table for efficient checksum computation.

Example

#include <stdio.h>
#include "crc32.h"

int main() {
	unsigned char data[] = "halloweeks";
	
	crc32_t crc = crc32(data, sizeof(data) - 1);
	
	printf("crc: %08x\n", crc);
	return 0;
}

Example 2

#include <stdio.h>
#include "crc32.h"

int main() {
	unsigned char data1[] = "hallo";
	unsigned char data2[] = "weeks";
	
	crc32_t crc = crc32_init();
	
	crc = crc32_update(crc, data1, 5);
	crc = crc32_update(crc, data2, 5);
	
	crc = crc32_final(crc);
	
	printf("crc: %08x\n", crc);
	return 0;
}

CRC32 Table Generator

unsigned int crc32_table[256] = {0};

void make_crc_table(unsigned int crcTable[]) {
    const unsigned int POLYNOMIAL = 0xEDB88320;

    for (unsigned int b = 0; b < 256; ++b) {
        unsigned int remainder = b;
        for (unsigned int bit = 0; bit < 8; ++bit) {
            if (remainder & 1)
       
4B34
         remainder = (remainder >> 1) ^ POLYNOMIAL;
            else
                remainder >>= 1;
        }
        crcTable[b] = remainder;
    }
}

About

A C language implementation of the CRC-32 algorithm using the polynomial 0xEDB88320. Includes a pre-computed lookup table for efficient checksum computation.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

0