std.crc32
CRC-32, the checksum of IEEE 802.3 that zlib, gzip, zip and PNG keep:
the bytes’ remainder by the polynomial 0x04c11db7, its bits reflected
(0xedb88320), begun at and inverted by 0xffffffff — Go’s
crc32.ChecksumIEEE. It finds bytes changed by accident, not on
purpose: anyone can make bytes of a given CRC. Written in heff, a
byte at a time by a table of 256.
import bytes as Bytesimport std.crc32 as CRC32
-- | whether a zip entry's content is what its header says it wasunchanged : Bytes -> UInt32 -> Boolunchanged content recorded = CRC32.checksum content == recordedchecksum
checksum : Bytes -> UInt32The CRC-32 of the bytes: of “123456789”, 0xcbf43926.
>>> checksum (Bytes.fromString "123456789")3421780262>>> checksum (Bytes.fromString "123456789") == 0xcbf43926True>>> checksum Bytes.empty0>>> checksum (Bytes.fromString "The quick brown fox jumps over the lazy dog") == 0x414fa339True