From: Lutz Donnerhacke <lutz@iks-jena.de>
Subject: Re: Question about Ada and constant Arrays
Date: Tue, 11 Nov 2003 09:34:51 +0000 (UTC)
Date: 2003-11-11T09:34:51+00:00 [thread overview]
Message-ID: <slrnbr1b9r.nt.lutz@taranis.iks-jena.de> (raw)
In-Reply-To: hkPrb.6700$bQ3.6409@nwrdny03.gnilink.net
* Stephane Richard wrote:
> I'd like to make an constant array of a given record type and initialize it
> upon it's creation.
package Hex_Strings is
type Hex_String is new String;
function To_Data(h : Hex_String) return String;
function To_Hex(d : String) return Hex_String;
type Debug_Types is (Hexify, Dehexify);
debug : array(Debug_Types) of Boolean := (others => False);
end Hex_Strings;
with Hex_Strings;
package Tests is
type Constant_String is access constant String;
type Constant_String_Array is array(Positive range <>) of Constant_String;
type Constant_Hex_String is access constant Hex_Strings.Hex_String;
type Constant_Hex_String_Array is array(Positive range <>) of Constant_Hex_String;
end Tests;
with Tests, Hex_Strings;
use Tests, Hex_Strings;
pragma Elaborate_All(Hex_Strings, Tests);
package RfC2202 is
sha1_k1 : aliased constant String := (1 .. 20 => Character'Val(16#0b#));
md5_k1 : aliased constant String := (1 .. 16 => Character'Val(16#0b#));
d1 : aliased constant String := "Hi There";
sha1_1 : aliased constant Hex_String := "b6173186 55057264 e28bc0b6 fb378c8e f146be00";
md5_1 : aliased constant Hex_String := "9294727a 3638bb1c 13f48ef8 158bfc9d";
sha1_k2 : aliased constant String := "Jefe";
md5_k2 : String renames sha1_k2;
d2 : aliased constant String := "what do ya want for nothing?";
sha1_2 : aliased constant Hex_String := "effcdf6a e5eb2fa2 d27416d5 f184df9c 259a7c79";
md5_2 : aliased constant Hex_String := "750c783e 6ab0b503 eaa86e31 0a5db738";
sha1_k3 : aliased constant String := (1 .. 20 => Character'Val(16#aa#));
md5_k3 : aliased constant String := (1 .. 16 => Character'Val(16#aa#));
d3 : aliased constant String := (1 .. 50 => Character'Val(16#dd#));
sha1_3 : aliased constant Hex_String := "125d7342 b9ac11cd 91a39af4 8aa17b4f 63f175d3";
md5_3 : aliased constant Hex_String := "56be3452 1d144c88 dbb8c733 f0e8b3f6";
sha1_k4 : aliased constant String := To_Data("0102030405060708090a0b0c0d0e0f10111213141516171819");
md5_k4 : String renames sha1_k4;
d4 : aliased constant String := (1 .. 50 => Character'Val(16#cd#));
sha1_4 : aliased constant Hex_String := "4c9007f4 026250c6 bc8414f9 bf50c86c 2d7235da";
md5_4 : aliased constant Hex_String := "697eaf0a ca3a3aea 3a751647 46ffaa79";
sha1_k5 : aliased constant String := (1 .. 20 => Character'Val(16#0c#));
md5_k5 : aliased constant String := (1 .. 16 => Character'Val(16#0c#));
d5 : aliased constant String := "Test With Truncation";
sha1_5 : aliased constant Hex_String := "4c1a0342 4b55e07f e7f27be1 d58bb932 4a9a5a04";
md5_5 : aliased constant Hex_String := "56461ef2 342edc00 f9bab995 690efd4c";
sha1_k6 : aliased constant String := (1 .. 80 => Character'Val(16#aa#));
md5_k6 : String renames sha1_k6;
d6 : aliased constant String := "Test Using Larger Than Block-Size Key - Hash Key First";
sha1_6 : aliased constant Hex_String := "aa4ae5e1 5272d00e 95705637 ce8a3b55 ed402112";
md5_6 : aliased constant Hex_String := "6b1ab7fe 4bd7bf8f 0b62e6ce 61b9d0cd";
sha1_k7 : String renames sha1_k6;
md5_k7 : String renames sha1_k7;
d7 : aliased constant String := "Test Using Larger Than Block-Size Key and Larger Than One Block-Size Data";
sha1_7 : aliased constant Hex_String := "e8e99d0f 45237d78 6d6bbaa7 965c7808 bbff1a91";
md5_7 : aliased constant Hex_String := "6f630fad 67cda0ee 1fb1f562 db3aa53e";
sha1_keys : constant Constant_String_Array := (
sha1_k1'Access, sha1_k2'Access, sha1_k3'Access, sha1_k4'Access,
sha1_k5'Access, sha1_k6'Access, sha1_k7'Access
);
sha1_data : constant Constant_String_Array := (
d1'Access, d2'Access, d3'Access, d4'Access,
d5'Access, d6'Access, d7'Access
);
sha1_hashes : constant Constant_Hex_String_Array := (
sha1_1'Access, sha1_2'Access, sha1_3'Access, sha1_4'Access,
sha1_5'Access, sha1_6'Access, sha1_7'Access
);
md5_keys : constant Constant_String_Array := (
md5_k1'Access, md5_k2'Access, md5_k3'Access, md5_k4'Access,
md5_k5'Access, md5_k6'Access, md5_k7'Access
);
md5_data : Constant_String_Array renames sha1_data;
md5_hashes : constant Constant_Hex_String_Array := (
md5_1'Access, md5_2'Access, md5_3'Access, md5_4'Access,
md5_5'Access, md5_6'Access, md5_7'Access
);
end RfC2202;
prev parent reply other threads:[~2003-11-11 9:34 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-11-10 16:49 Question about Ada and constant Arrays Stephane Richard
2003-11-10 17:07 ` Preben Randhol
2003-11-10 17:10 ` Stephane Richard
2003-11-10 17:13 ` Preben Randhol
2003-11-10 17:11 ` Preben Randhol
2003-11-11 5:41 ` Nick Roberts
2003-11-11 9:34 ` Lutz Donnerhacke [this message]
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox