From: wvxvw <olegsivokon@gmail.com>
Subject: Re: GNAT.SHA256 produces result different from sha257sum on Linux
Date: Sat, 04 Nov 2023 20:26:34 +0100 [thread overview]
Message-ID: <8734xlgw0l.fsf@gmail.com> (raw)
In-Reply-To: 87bkc9mmld.fsf@bsb.me.uk
Ben Bacarisse <ben.usenet@bsb.me.uk> writes:
> 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.
Yeah, thanks! I realized this too by trying to do this in Python:
>>> import hashlib
>>> hashlib.sha256('foo'.encode()).hexdigest()
'2c26b46b68ffc68ff99b453c1d30413413422d706483bfa0f98a5e886266e7ae'
>>> hashlib.sha256('foo\n'.encode()).hexdigest()
'b5bb9d8014a0f9b1d61e21e796d78dccdf1352f23cd32812f4850b878ae4944c'
Thanks again.
next prev parent reply other threads:[~2023-11-04 19:26 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 [this message]
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