From: Ben Bacarisse <ben.usenet@bsb.me.uk>
Subject: Re: GNAT.SHA256 produces result different from sha257sum on Linux
Date: Sat, 04 Nov 2023 17:53:34 +0000 [thread overview]
Message-ID: <87bkc9mmld.fsf@bsb.me.uk> (raw)
In-Reply-To: 877cmxh3cs.fsf@gmail.com
wvxvw <olegsivokon@gmail.com> writes:
> "Jeffrey R.Carter" <spam.jrcarter.not@spam.acm.org.not> writes:
>
>> 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.
>
> Hi, thanks for the idea, but no, that's not it.
You say that's not it, but with the newline removed, sha256sum gives the
same hash as your original test code:
$ printf foo | sha256sum -
2c26b46b68ffc68ff99b453c1d30413413422d706483bfa0f98a5e886266e7ae -
From your earlier post:
> Eg, with GNAT.SHA256 for string "foo" I get:
>
> ❯ ./bin/test_sha --arg foo
> 2c26b46b68ffc68ff99b453c1d30413413422d706483bfa0f98a5e886266e7ae
> With the line end added
> I get 04e1806fda6bdbc9e5e3534edd993c7c2bf03173f5489742db53d1e8b0ef8c61
> from Ada.
Ah! You didn't add a newline! I can get the same hash by guesswork:
$ printf foo\\\\n >input
$ sha256sum input
04e1806fda6bdbc9e5e3534edd993c7c2bf03173f5489742db53d1e8b0ef8c61 input
$ hd input
00000000 66 6f 6f 5c 6e |foo\n|
00000005
What you added to the test string was a backslash and a letter n.
--
Ben.
next prev parent reply other threads:[~2023-11-04 17:53 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 [this message]
2023-11-04 19:26 ` wvxvw
2023-11-04 16:49 ` Niklas Holsti
2023-11-04 17:39 ` Jeffrey R.Carter
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox