wvxvw <
olegs...@gmail.com> writes:
> "Jeffrey R.Carter" <spam.jrc...@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.