From mboxrd@z Thu Jan 1 00:00:00 1970 Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: wvxvw Newsgroups: comp.lang.ada Subject: Re: GNAT.SHA256 produces result different from sha257sum on Linux Date: Sat, 04 Nov 2023 20:26:34 +0100 Organization: A noiseless patient Spider Message-ID: <8734xlgw0l.fsf@gmail.com> References: <87bkc9h9au.fsf@gmail.com> <877cmxh3cs.fsf@gmail.com> <87bkc9mmld.fsf@bsb.me.uk> MIME-Version: 1.0 Content-Type: text/plain Injection-Info: dont-email.me; posting-host="d272cbac82ad59a2f68bf01ec9dc5e6d"; logging-data="3706884"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18lfjFWxR+ScwvwG1IbUaG0" User-Agent: Gnus/5.13 (Gnus v5.13) Cancel-Lock: sha1:FheHSADzU8FbHUUzbUcvLvSAATg= sha1:rfweWZMGYzWuP0l6jBnkkkVXGqw= Xref: news.eternal-september.org comp.lang.ada:65842 List-Id: Ben Bacarisse 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.