src/crc.bend checks
raw source on the hub · import 0x57618559b9b26dd8415f821176a3e692/src/crc.bend as Crc
src/crc: CRC-32. PNG covers the chunk type and the chunk data with the ISO 3309 / ITU-T V.42 polynomial (ISO/IEC 15948 / W3C PNG).
1 import
import Base
Definitions
def crc.poly source · line 6 · raw
U32
the reflected polynomial
def crc.bit source · line 10 · raw
@nn:Nat -> @odd:Bool -> @+cc:U32 -> U32
eight shifts, one per bit, low bit first. The Nat shrinks, so it is first.
def crc.byte source · line 22 · raw
@+cc:U32 -> @+bb:U32 -> U32
fold one byte into the register
def crc.fold source · line 27 · raw
@xs:List<&2, U32> -> @+cc:U32 -> U32
fold every byte, register still inverted. The list shrinks, so it is first.
def crc32 source · line 35 · raw
@xs:List<&2, U32> -> U32
CRC-32 of the bytes, init and final xor all ones