std/text/checksum
std/checksum — non-cryptographic data integrity checks.
CRC32 follows the IEEE 802.3 polynomial (same as zlib / gzip).
Adler-32 is RFC 1950 (zlib's other hash). Both are streaming-
friendly : pass the previous result as the seed to extend an
existing checksum without re-hashing.
Use std/hashing for HashMap keys; std/crypto for
security-relevant integrity. These are for "did the file arrive
intact" / "is the cache stale" checks.
Implemented in pure Axle.
Free functions
| Type | Method and description |
|---|---|
| crc32Update(seed : i64, data : string) : i64 IEEE 802.3 CRC32, reflected form. POLY = 0xEDB88320, mask = 0xFFFFFFFF. Table-less inner loop : 8 polynomial divisions per byte. Slower than a 256-entry lookup, but the algorithm is exact. |
| crc32(data : string) : i64 Convenience seed-0 entry point: the CRC32 of data on its own. |
| adler32Update(seed : i64, data : string) : i64 Adler-32 (RFC 1950). a = 1, b = 0 initially. per byte : a = (a + byte) % MOD ; b = (b + a) % MOD. result = (b << 16) | a. |
| adler32(data : string) : i64 Convenience seed-0 entry point: the Adler-32 of data on its own. |
Method detail
#crc32Update
IEEE 802.3 CRC32, reflected form.
POLY = 0xEDB88320, mask = 0xFFFFFFFF.
Table-less inner loop : 8 polynomial divisions per byte. Slower
than a 256-entry lookup, but the algorithm is exact.
seed previous CRC32 result to extend (0 to start fresh)data bytes to fold into the running checksum#crc32
Convenience seed-0 entry point: the CRC32 of data on its own.
data bytes to checksum#adler32Update
Adler-32 (RFC 1950).
a = 1, b = 0 initially.
per byte : a = (a + byte) % MOD ; b = (b + a) % MOD.
result = (b << 16) | a.
seed previous Adler-32 result to extend (0 to start fresh)data bytes to fold into the running sums a and b#adler32
Convenience seed-0 entry point: the Adler-32 of data on its own.
data bytes to checksum