comp.lang.ada
 help / color / mirror / Atom feed
From: "Jeffrey R.Carter" <spam.jrcarter.not@spam.acm.org.not>
Subject: Re: GNAT.SHA256 produces result different from sha257sum on Linux
Date: Sat, 4 Nov 2023 18:39:51 +0100	[thread overview]
Message-ID: <ui5vl7$3d0f4$2@dont-email.me> (raw)
In-Reply-To: <kqnb1mFnvc6U1@mid.individual.net>

> On 2023-11-04 17:09, Jeffrey R.Carter wrote:
>> On 2023-11-04 15:39, wvxvw wrote:
>>>
>>> ❯ ./bin/test_sha --arg foo
>>> 2c26b46b68ffc68ff99b453c1d30413413422d706483bfa0f98a5e886266e7ae
>>> ❯ echo foo | sha256sum -
>>> b5bb9d8014a0f9b1d61e21e796d78dccdf1352f23cd32812f4850b878ae4944c  -
>>
>> I think the problem may be that echo adds an LF:
>>
>> $ echo foo | hd
>> 00000000  66 6f 6f 0a                                       |foo.|
>>
>> Since sha256sum expects to work on arbitrary files, it would include the LF in 
>> its input.

wvxvw wrote:
 >
> Hi, thanks for the idea, but no, that's not it.  With the line end added
> I get 04e1806fda6bdbc9e5e3534edd993c7c2bf03173f5489742db53d1e8b0ef8c61
> from Ada.

On 2023-11-04 17:49, Niklas Holsti wrote:
> 
> Some implementations of "echo" accept an option "-n" to suppress the trailing 
> newline (LF). The OP could try that option as a quick check of this answer 
> (which seems very plausible).

$ echo -n foo | hd
00000000  66 6f 6f                                          |foo|
$ echo -n foo | sha256sum -
2c26b46b68ffc68ff99b453c1d30413413422d706483bfa0f98a5e886266e7ae  -

Interesting results.

-- 
Jeff Carter
"You can never forget too much about C++."
115

      reply	other threads:[~2023-11-04 17:39 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-04 14:39 GNAT.SHA256 produces result different from sha257sum on Linux wvxvw
2023-11-04 15:09 ` Jeffrey R.Carter
2023-11-04 16:48   ` wvxvw
2023-11-04 17:53     ` Ben Bacarisse
2023-11-04 19:26       ` wvxvw
2023-11-04 16:49   ` Niklas Holsti
2023-11-04 17:39     ` Jeffrey R.Carter [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