Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

Mathematicians practice absolute freedom. -- Henry Adams


devel / comp.lang.ada / GNAT.SHA256 differs from Linux' sha256sum

SubjectAuthor
o GNAT.SHA256 differs from Linux' sha256sumwvxvw

1
GNAT.SHA256 differs from Linux' sha256sum

<87fs1lha1x.fsf_-_@gmail.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=10246&group=comp.lang.ada#10246

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!news.hispagatos.org!eternal-september.org!feeder2.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: olegsivokon@gmail.com (wvxvw)
Newsgroups: comp.lang.ada
Subject: GNAT.SHA256 differs from Linux' sha256sum
Date: Sat, 04 Nov 2023 15:23:22 +0100
Organization: A noiseless patient Spider
Lines: 41
Message-ID: <87fs1lha1x.fsf_-_@gmail.com>
References: <bqdd9uFo9g8U1@mid.individual.net> <lyk3b2wakf.fsf@pushface.org>
<AAh0v.5570$Ru1.3489@fx02.iad>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Injection-Info: dont-email.me; posting-host="d272cbac82ad59a2f68bf01ec9dc5e6d";
logging-data="3584007"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19iS6L8gSZEBthkJp+YWJEa"
User-Agent: Gnus/5.13 (Gnus v5.13)
Cancel-Lock: sha1:2123H/RcShMAEPMrSKdsh6mY6x8=
sha1:2zbkU3CoELkaRpsROVz1YCrPFDk=
 by: wvxvw - Sat, 4 Nov 2023 14:23 UTC

Hello.

I'm learning Ada as well as how to use Usenet, so don't be too harsh.
As a learning exercise, I want to write a program that, beside other
things, needs to compute SHA256 hashes. I discovered GNAT.SHA256
library and was able to use it (by calling Digest(<some string>)),
however the result is different from what I'd get for the same string
with running sha256sum.

Eg, with GNAT.SHA256 for string "foo" I get:

❯ ./bin/test_sha --arg foo
2c26b46b68ffc68ff99b453c1d30413413422d706483bfa0f98a5e886266e7ae
❯ echo foo | sha256sum -
b5bb9d8014a0f9b1d61e21e796d78dccdf1352f23cd32812f4850b878ae4944c -

My Ada code looks (with some unrelated stuff removed) like this:

with GNAT.Command_Line; use GNAT.Command_Line;
with GNAT.SHA256; use GNAT.SHA256;

procedure Main is
loop
case Getopt ("-arg=") is
when '-' =>
if Full_Switch = "-arg" then
Put_Line (Digest (Parameter));
end if;
end case;
end loop;
end Main;

My understanding is that there are plenty of configuration settings to
how the checksum is computed, but I know very little about it. My goal
is to produce the same checksum as would be produced by sha256sum
though, as the checksums are to be used outside of my program.

Finally: is GNAT.SHA256 a good way to go if I need this functionality (I
don't care about portability, if that's a concern)?

Thanks!

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor