Simple program to get sha256 hash

Ralph Corderoy ralph at inputplus.co.uk
Fri Mar 17 23:15:43 CET 2017


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



More information about the Gnupg-users mailing list