tinycodinglm / misc /misc-0002.jsonl
winapiadmin's picture
Upload folder using huggingface_hub (part 16)
d517dc9 verified
|
Raw History Blame
1.24 kB
opencode trace
System You are an expert programmer.

You are an expert programmer.

User

Explain CRC and checksum algorithms

Assistant

CRC (Cyclic Redundancy Check): polynomial division over GF(2).
CRC-32: divides data by generator polynomial x^32+x^26+x^23+...+1, remainder is 32-bit checksum.
Used in: Ethernet, ZIP, PNG, gzip.

Computation: process bits, XOR with polynomial when MSB is 1. Table-based: precompute 256-entry table for byte-at-a-time.

Variants: CRC-8 (1-wire), CRC-16 (Modbus, USB), CRC-32 (Ethernet, zlib), CRC-64 (XZ).

Checksum: simpler. Fletcher-16: sum of bytes, sum of running sums. Adler-32: same idea, faster.
IP header: ones' complement sum of 16-bit words.

MD5/SHA: cryptographic hashes, not just error detection. Much slower but collision-resistant.

Fletcher vs CRC: Fletcher is simpler but weaker. CRC detects burst errors up to polynomial degree. Both are for error detection, not correction.

Applications: network packets, file integrity, compression, storage.