lib.bend checks
raw source on the hub · import 0xff0c68fa4ce715b1f30ee5944192f0b7/lib.bend as Lib
Crc32 — Base-only CRC-32 (ISO 3309 / Ethernet).
Input is a List<&2, U32>. Each element is an octet; only its low eight bits are consumed. The state uses the reflected polynomial 0xEDB88320.
1 import
import Base
Definitions
def Crc32.init source · line 8 · raw
U32
Reflected CRC-32 constants. 0xFFFFFFFF is expressed as bitwise not of zero.
def Crc32.polynomial source · line 11 · raw
U32
def Crc32.step source · line 16 · raw
@+crc:U32 -> U32
One reflected bit step. The low state bit selects whether the polynomial is XORed after the logical right shift.
def Crc32.byte.go source · line 24 · raw
@n:Nat -> @+crc:U32 -> U32
Process exactly eight bits of one octet.
def Crc32.byte source · line 31 · raw
@+octet:U32 -> @+crc:U32 -> U32
def Crc32.update.go source · line 35 · raw
@xs:List<&2, U32> -> @+crc:U32 -> U32
Update the unfinalized CRC state over a list of octets.
def Crc32.update source · line 42 · raw
@+crc:U32 -> @xs:List<&2, U32> -> U32
def Crc32.finalize source · line 47 · raw
@+crc:U32 -> U32
Apply the standard final XOR. update leaves this step to the caller so
chunks can be processed incrementally.
def Crc32.encode source · line 50 · raw
@xs:List<&2, U32> -> U32