std.adler32
Adler-32, the checksum of RFC 1950 that zlib keeps: two sums of the
bytes, each modulo 65521, the largest prime below 65536 — a, 1 and
each byte, and b, each a so far — as b times 65536 and a, Go’s
adler32.Checksum. It is quicker than a CRC-32, and weaker over few
bytes; it finds bytes changed by accident, not on purpose.
import bytes as Bytesimport std.adler32 as Adler32
-- | whether a zlib stream's data is what its trailer says it wasunchanged : Bytes -> UInt32 -> Boolunchanged content recorded = Adler32.checksum content == recordedchecksum
checksum : Bytes -> UInt32The Adler-32 of the bytes: of “Wikipedia”, 0x11e60398.
>>> checksum (Bytes.fromString "Wikipedia") == 0x11e60398True>>> checksum Bytes.empty1>>> checksum (Bytes.fromString "The quick brown fox jumps over the lazy dog") == 0x5bdc0fdaTrue>>> checksum (Bytes.fromList (List.replicate 100000 255)) == 0x149a302cTrue