Digest

digest is a small tool which eats a file or stream and can generate multiple hashes at once.

It started off as a little tool which I threw together for fun to implement the Tiger hash algorithm in a way that could be built using a strict C90 compiler that may have no 64-bit type. It uses an abstraction to create a 64-bit type which is manipulated by operators hopefully in a neat looking way. When using a compiler which has a 64-bit type, these operators will just become macros which expand out to normal C operators and the code should run at close to the reference speed (the algorithms seem to run acceptably fast on my laptop). I've tried to make code look as simple (or simpler in some cases than) the reference implementation and I've also tried to abstract away any feral-macro-hacks which try to deal with system endianness.

digest has support for the MD4, MD5, Tiger, SHA1, SHA2 and SHA3 hashing functions and also has support for creating a root hash of a Merkle tree for any of these algorithms with an arbitrary block size. The output format can also be selected as hex, base32 or base64.

There is a unit test application which tests all of the internal hash functions which can be built and executed using make check.

digest is licensed under a BSD 3-clause license and the source code is available on GitHub here: https://github.com/nickappleton/digest/.

Examples:

echo -n "abc" | ./digest md5
900150983CD24FB0D6963F7D28E17F72 
echo -n "abc" | ./digest md5 tiger tree.1024:tiger:base64
900150983CD24FB0D6963F7D28E17F72 2AAB1484E8C158F2BFB8C5FF41B57A525129131C957B5F93 KqsUhOjBWPK/uMX/QbV6UlEpExyVe1+T  
./digest md5 sha1:base32 -f ./digest
E0B30B8542E692D5E48A324971A77EBD YECY3WA7RJCFMSEOXMTGNHT7QQNZXWQ5 

I will not provide binaries.

Leave a Reply

Your email address will not be published. Required fields are marked *