

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


/**
 <doc>CRC32 in Neko</doc>
**/
 
var int32_new = $loader.loadprim("std@int32_new", 1)
var update_crc32 = $loader.loadprim("zlib@update_crc32", 4)
 
var crc = int32_new(0)
var txt = "The quick brown fox jumps over the lazy dog"
 
crc = update_crc32(crc, txt, 0, $ssize(txt))
$print(crc, "\n")