

Task

Demonstrate a method of deriving the Cyclic Redundancy Check from within the language.



The result should be in accordance with ISO 3309, ITU-T V.42, Gzip and PNG.

Algorithms are described on Computation of CRC in Wikipedia.
This variant of CRC-32 uses LSB-first order, sets the initial CRC to FFFFFFFF16, and complements the final CRC.

For the purpose of this task, generate a CRC-32 checksum for the ASCII encoded string:

 The quick brown fox jumps over the lazy dog


V crc_table = [0] * 256
L(i) 256
   UInt32 rem = i
   L 8
      I rem [&] 1 != 0
         rem >>= 1
         rem (+)= EDB8'8320
      E
         rem >>= 1
   crc_table[i] = rem
 
F crc32(buf, =crc = UInt32(0))
   crc = (-)crc
   L(k) buf
      crc = (crc >> 8) (+) :crc_table[(crc [&] F'F) (+) k.code]
   R (-)crc
 
print(hex(crc32(‘The quick brown fox jumps over the lazy dog’)))