Zum Inhalt springen
uencoder

Checksum Algorithmen Referenz

Non-cryptographic checksums: CRC32, Adler-32, Fletcher, und ihre polynomial representations.

CRC Family

Cyclic Redundancy Check codes treat the input as a polynomial over GF(2) and compute the remainder after division by a generator polynomial. The generator determines the error-detection capability: CRC-32 with the standard polynomial detects all single and double-bit errors and all burst errors up to 32 bits. Different CRC variants use different polynomials, bit reflection, and initial values, so a CRC-32 from one library may not match another.

CRC-32
Standard Ethernet polynomial 0x04C11DB7, 32-bit
zlib, PNG
CRC-32C
Castagnoli polynomial, better error detection
iSCSI, SCTP
CRC-16-CCITT
16-bit, polynomial 0x1021
X.25, Bluetooth
Adler-32
Sum and modulo checksum, faster than CRC-32
zlib header

Error Detection Capability

Checksums detect accidental corruption but are not resistant to intentional modification. CRC-32 detects burst errors up to its degree with probability 1, and longer bursts with high probability. Random data corruption is detected with probability roughly 1 minus 2 to the negative 32. For adversarial tampering, a cryptographic MAC is required because an attacker can recompute the checksum after modifying the data.

Performance Considerations

CRC computations can be accelerated with table-based lookups that process one byte per iteration, or slice-by-N variants that process multiple bytes per table lookup. Modern CPUs offer hardware CRC-32C instructions that process bytes at memory bandwidth. Adler-32 is simpler and faster on short inputs but has weaker error detection than CRC-32. The choice depends on the throughput requirements and error model of the application.

Verwandte Tools

参考链接