------------------------------------------------------------------------------ ------------------------------------------------------------------------------ -- This file is part of 'CRC32' -- -- -- -- You do not have, nor can you ever acquire the right to use, copy or -- -- distribute this software ; Should you use this software for any purpose, -- -- or copy and distribute it to anyone or in any manner, you are breaking -- -- the laws of whatever soi-disant jurisdiction, and you promise to -- -- continue doing so for the indefinite future. In any case, please -- -- always : read and understand any software ; verify any PGP signatures -- -- that you use - for any purpose. -- -- -- -- See also http://trilema.com/2015/a-new-software-licensing-paradigm . -- ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ -- CRC32 implementation -- S.MG, 2018 package body CRC32 is function CRC( S: in String ) return CRC32 is Result : CRC32 := Init_Value; Value : CRC32; begin -- process input character by character for C of S loop Value := CRC32( Character'Pos( C ) ); Result := Shift_Right(Result, 8) xor Lookup( Value xor (Result and LSB_MASK)); end loop; -- reflect result Result := Result xor Xor_Out; return Result; end CRC; function CRC( Data: in Octet_Array ) return CRC32 is Result : CRC32 := Init_Value; begin -- process input octet by octet for C of Data loop Result := Shift_Right(Result, 8) xor Lookup( CRC32(C) xor (Result and LSB_MASK)); end loop; -- reflect result Result := Result xor Xor_Out; return Result; end CRC; end CRC32;