Skip to content


Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time
# status

works.  passes tests.

# intro

this is a SHA-2 library and example tools, written to directly
reflect the description of the algorithm in the FIPS 180-3 standard.
it is not optimized for speed.  it is in written portable c but assumes
ints are 32 bits and long longs are 64 bits.  it includes a simple
program that can verify against the official test vectors.  the code is
in the public domain for easy inclusion in other software.

# install

run "make" to compile the library (sha2.c) and the programs sha256
and sha512.  there is no "install" target.  see "testing" below for
testing against the test vectors.

sha256 and sha512 calculate the hash on the data read from their
standard input.  specifying the -o option makes them run the shorter
output of the algorithm, resulting in 224 bits for sha256 and 384
for sha512.

# latest version

get it from

# licence & author

all files are in the public domain.  this code has been written by
mechiel lukkien, reachable at or

# testing

for testing, you'll need the test vectors:

which is linked as "SHA Test Vectors for Hashing Byte-Oriented Messages" from:

extract the files from to this directory and
run "make test".  each test prints a dot.  errors are printed on
mismatch.  if no errors are printed (and the program exits with
success status), all tests passed.


sha2, c, from mercurial






No releases published


No packages published