

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


with Ada.Text_IO; use Ada.Text_IO;
with GNAT.CRC32; use GNAT.CRC32;
with Interfaces; use Interfaces;
procedure TestCRC is
   package IIO is new Ada.Text_IO.Modular_IO (Unsigned_32);
   crc : CRC32;
   num : Unsigned_32;
   str : String := "The quick brown fox jumps over the lazy dog";
begin
   Initialize (crc);
   Update (crc, str);
   num := Get_Value (crc);
   IIO.Put (num, Base => 16); New_Line;
end TestCRC;