Adler_32_crc (adler_32_crc.ads): (Body)


--  © Copyright 2000 by John Halleck, All Rights Reserved.
--  Adler-32 CRC.  This is the CRC used by ZLIB compression.
--  This algorithm is described in the the Zlib RFC 1950 May 1996, titled
--  "RFC 1950 ZLIB Compressed Data Format Specification".
--  It is claimed to be an extension and improvement of the Fletcher algorithm
--  used in ITU-T X.224 / ISO 8073.

with Interfaces; use Interfaces;
--  Unsigned_8, Unsigned_32
package Adler_32_CRC is
   pragma Pure (Adler_32_CRC);

   type CRC is new Unsigned_32;


   --  Full processing.
   type State is private;

   procedure Initialize (Given : out State); -- Start out a state.
   pragma Inline (Initialize);

   procedure Process_Data (Given : in out State; Byte : Unsigned_8);
   pragma Inline (Process_Data);

   function  Final_CRC   (Given :  in State) return CRC;
   pragma Inline (Final_CRC);


   --  Just CRC a string.
   function Process_String (Given : String) return CRC;

private

   Base : constant Unsigned_16 := 65521;
   --  This is the largest prime number that fits in 16 bits

   type Accumulation is mod Base;
  
   type State is record  --  Taken directly from the spec.
      s1 : Accumulation;
      s2 : Accumulation;
   end record;

end Adler_32_CRC;

Go to ...


This page is http://www.cc.utah.edu/~nahaj/ada/crc/adler_32_crc.ads.html
© Copyright 2000 by John Halleck, All Rights Reserved.
This snapshot was last modified on August 11th, 2000
And the underlying file was last modified on August 5th, 2000