-
+ 936D9785BC02F35A58AC415074D9A7DAA857D24AF3093BAEA9BBF082D71E83EDB881EFCD2FCE95F774F600C6A99E8FE8F3C2C2EF7553C1E72556C31F6C7B7C3A
eucrypt/crc32/crc32.adb
(0 . 0)(1 . 52)
5 ------------------------------------------------------------------------------
6 ------------------------------------------------------------------------------
7 -- This file is part of 'CRC32' --
8 -- --
9 -- You do not have, nor can you ever acquire the right to use, copy or --
10 -- distribute this software ; Should you use this software for any purpose, --
11 -- or copy and distribute it to anyone or in any manner, you are breaking --
12 -- the laws of whatever soi-disant jurisdiction, and you promise to --
13 -- continue doing so for the indefinite future. In any case, please --
14 -- always : read and understand any software ; verify any PGP signatures --
15 -- that you use - for any purpose. --
16 -- --
17 -- See also http://trilema.com/2015/a-new-software-licensing-paradigm . --
18 ------------------------------------------------------------------------------
19 ------------------------------------------------------------------------------
20
21 -- CRC32 implementation
22 -- S.MG, 2018
23
24 package body CRC32 is
25 function CRC( S: in String ) return CRC32 is
26 Result : CRC32 := Init_Value;
27 Value : CRC32;
28 begin
29 -- process input character by character
30 for C of S loop
31 Value := CRC32( Character'Pos( C ) );
32 Result := Shift_Right(Result, 8) xor
33 Lookup( Value xor (Result and LSB_MASK));
34 end loop;
35 -- reflect result
36 Result := Result xor Xor_Out;
37
38 return Result;
39 end CRC;
40
41 function CRC( Data: in Octet_Array ) return CRC32 is
42 Result : CRC32 := Init_Value;
43 begin
44 -- process input octet by octet
45 for C of Data loop
46 Result := Shift_Right(Result, 8) xor
47 Lookup( CRC32(C) xor (Result and LSB_MASK));
48 end loop;
49 -- reflect result
50 Result := Result xor Xor_Out;
51
52 return Result;
53 end CRC;
54
55 end CRC32;
56