Can't you just use this, from coreutils? Or re-use their code.
knoppix@Microknoppix:~$ sha256sum --version
sha256sum (GNU coreutils) 8.4
Copyright (C) 2010 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later
<http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Written by Ulrich Drepper, Scott Miller, and David Madore.
knoppix@Microknoppix:~$ echo -n '' | sha256sum
e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 -
knoppix@Microknoppix:~$
-----Original-Nachricht-----
Subject: programming advice, calculating a sha256 hash
Date: Mon, 11 Jul 2011 08:44:49 +0200
From: Nathan Coulson <[email protected]>
To: General chatter list <[email protected]>
Probably not the normal use for this channel, but *shrug*, can't
hurt.
I was attempting to code a sha256 hash function, for hashing a
password before sending it over the open net. (Sounds like it's
better then md5 for this)
getting started, I found some psedocode at
http://en.wikipedia.org/wiki/SHA2 and went to work.
decided a blank string would be the best,
It gives me
74525b2e06b6cfebaa347250d2a6c6c9a5438fbbd4b44ffefe68dcdd7b1d1206
but according to wikipedia above, it should be
e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
--
Nathan Coulson (conathan)
------
Location: British Columbia, Canada
Timezone: PST (-8)
Webpage: http://www.nathancoulson.com
--
http://linuxfromscratch.org/mailman/listinfo/lfs-chat
FAQ: http://www.linuxfromscratch.org/faq/
Unsubscribe: See the above information page