From mboxrd@z Thu Jan 1 00:00:00 1970 Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: "Jeffrey R.Carter" Newsgroups: comp.lang.ada Subject: Re: GNAT.SHA256 produces result different from sha257sum on Linux Date: Sat, 4 Nov 2023 18:39:51 +0100 Organization: A noiseless patient Spider Message-ID: References: <87bkc9h9au.fsf@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Date: Sat, 4 Nov 2023 17:39:51 -0000 (UTC) Injection-Info: dont-email.me; posting-host="f17349dfb81b20de3803c6a532a5ed26"; logging-data="3572196"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX192FZxXWX8WVCp9r/KjE7A8IRXRpluS+OU=" User-Agent: Mozilla Thunderbird Cancel-Lock: sha1:ge2GXh8iZKqpGZubRuHOnSxc3Ik= Content-Language: en-US In-Reply-To: Xref: news.eternal-september.org comp.lang.ada:65840 List-Id: > 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