mario::konrad
programming / C++ / sailing / nerd stuff
Cryptographic Hash Functions
© 2010 / Mario Konrad

Disclaimer

All code downloadable below is provided under the BSD license.

Copyright (c) 2010, Mario Konrad. All rights reserved.

Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:

- Redistributions of source code must retain the above copyright notice, this list
  of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright notice, this
  list of conditions and the following disclaimer in the documentation and/or
  other materials provided with the distribution.
- The names of its contributors must not be used to endorse or promote products
  derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.

MD5

input hash
empty string d41d8cd98f00b204e9800998ecf8427e
The quick brown fox jumps over the lazy dog 9e107d9d372bb6826bd81d3542a419d6

SHA-1

input hash
empty string da39a3ee5e6b4b0d3255bfef95601890afd80709
The quick brown fox jumps over the lazy dog 2fd4e1c67a2d28fced849ee1bb76e7391b93eb12

SHA-224

input hash
empty string d14a028c2a3a2bc9476102bb288234c415a2b01f828ea62ac5b3e42f
The quick brown fox jumps over the lazy dog 730e109bd7a8a32b1cb9d9a09aa2325d2430587ddbc0c38bad911525

SHA-256

input hash
empty string e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
The quick brown fox jumps over the lazy dog d7a8fbb307d7809469ca9abcb0082e4f8d5651e46d3cdb762d02d0bf37c9e592

Common

The classes shown above need endianess handling.

Download

Download all files a one archive:

Test

Build and run tests:

$ for i in *.cpp ;do g++ -c $i ;done
$ g++ -o test *.o
$ ./test

or using make:

$ make
$ ./test