I am using GNAT.SHA1 to create a SHA1 hash of a string in Ada. My code base is small, so I'd like to avoid importing any libraries to the project that aren't provided by my compiler, hence I'm using GNAT.SHA1. As far as I'm aware, the only "public" methods for retrieving the hash is in String form via the Digest function. I would like to instead get the 160-bit block that is the H member of the Context type. Unfortunately, the Context record is private. Is there any way I can get at it? Or is their an alternative method provided by GNAT or the Ada standard library?
Getting the SHA1 block from GNAT.SHA1
485 Views Asked by Anthony At
1
I don't know of any direct way to get the 160-bit block, but of course you can compute it from the hexadecimal string.
Here's an example I just threw together. (Granted, extracting 32-bit integers by adding
"16#"and"#"to the hex substring may not be the most elegant solution.The output is: