On Fri, Mar 17, 2017 at 11:15 PM, Ralph Corderoy <ra...@inputplus.co.uk> wrote: > Hi Paolo, > >> $ gcc -o ssha ./hash.cpp -lgcrypt >> $ ./ssha blablabla >> a6898dd93b4c6a87e978aea8547fdc3901b7b94d96636e03d5a6194f4491c571 > > You're feeding it nine bytes here. > >> $ sha256sum <<< 'blablabla' >> a5edca3a5b8fb54ae61d236a5274626ba6a38781573e02202000158faa707191 - > > And ten bytes here. > > $ wc -c <<<blablabla > 10 > $ od -c <<<blablabla > 0000000 b l a b l a b l a \n > 0000012 > $ > > Further, you're incrementing the pointer before dereferencing. > > $ printf 'lablabla\0' | od -c > 0000000 l a b l a b l a \0 > 0000011 > $ printf 'lablabla\0' | sha256sum > a6898dd93b4c6a87e978aea8547fdc3901b7b94d96636e03d5a6194f4491c571 - > $ > > -- > Cheers, Ralph. > https://plus.google.com/+RalphCorderoy
Thanks everyone, it's dead on! $ echo -n 'blablabla' | sha256sum 492f3f38d6b5d3ca859514e250e25ba65935bcdd9f4f40c124b773fe536fee7d - $ ./a.out blablabla 492f3f38d6b5d3ca859514e250e25ba65935bcdd9f4f40c124b773fe536fee7d using echo -n "blablabla" gives indeed the same result! The flipped gcry_md_putc and ++c happened somewhat while I copied the code in the email, but indeed was another problem. Thanks again, Cheers Paolo _______________________________________________ Gnupg-users mailing list Gnupg-users@gnupg.org http://lists.gnupg.org/mailman/listinfo/gnupg-users