Giter Club home page Giter Club logo

hash-library's People

Contributors

stbrumme avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

hash-library's Issues

There is a memory leak

There is a memory leak, please add delete[] buffer; to line 64 (before return)

hash-library/digest.cpp

Lines 60 to 65 in f77b564

file.open(filename.c_str(), std::ios::in | std::ios::binary);
if (!file)
{
std::cerr << "Can't open '" << filename << "'" << std::endl;
return 2;
}

and the issue is fixed.
Best regards from the Cppcheck team ;-)

OSX has no endian.h

It seems OSX has no endian.h, but it also looks like it is not needed.

Possible solution to make sha256.cpp compile on OSX:

Replace

hash-library/sha256.cpp

Lines 9 to 12 in a8a88f8

// big endian architectures need #define __BYTE_ORDER __BIG_ENDIAN
#ifndef _MSC_VER
#include <endian.h>
#endif

with

#if !defined(_MSC_VER) && !defined(__APPLE__)
#include <endian.h>
#endif

digest.cpp is producing different hash for keccak256

I have build it from source using command
g++ -O3 digest.cpp crc32.cpp md5.cpp sha1.cpp sha256.cpp keccak.cpp sha3.cpp -o digest

Calculate the keccak256 for string 5aaeb6053f3e94c9b9a09f33669435e7ef1beaed
Actual hash: Keccak/256: d2a614d1f92994cd6f3e75fd233d568867fcdc638ab04a4dac5a719d7792ee6d

Expected hash: Keccak/256: d385650ce8fdc6db7ee3a091d34814dbc4ce18219ffae52182efff4034d707e5

I can see proper value at "Keccak and SHA3 Live Test" but when I try to use digest it produces different value.

No gethash(char[]) function in SHA3

Hello, thanks for this library! I didnt see a getHash(unsigned char buffer[HashBytes]) function in SHA3, wasn't sure why. Can you please let me know? Thanks!

Add hmac<SHA512>

Is there a way you could add the funcs in the SHA3 class, that would allow to use it with hmac ?

C language port of the library

This is not an issue per se, but I couldn't think of another way to approach this.
I was looking for a "small" (i.e. not libopenssl) hashing library in C, but didn't find anything. This library is perfect, but is, obviously, in C++.
So, I have ported the code back to C with as few changes as I could. I have not yet ported the tests, but running digest against a set of random files yields the same checksums from both the original and C version which gives me some confidence that I didn't introduce any glaring bugs.
The code retains all copyright notices and statements that Stephan is the original author/owner.
I was considering posting this to github, and realize that the license allows for this but wanted to get your blessing before doing so. If you were interested in adding the repo to github.com/stbrumme, that would also be great.

SHA3-512 bug

Hexadecimal string 72a5f501151ca974002f34 returns the wrong hash value. Actually any string which starts with 72a5f501151ca974 returns a wrong hash. Maybe related to 64-bit data type?

Keccak::getHash() is broken if no new data is added

Calling Keccak::getHash() repeatedly produces different hashes, SHA3 could be affected, too

int main(int argc, char *argv[]) {
    Keccak k;
    std::string temp("hello world");
    k.add(&temp[0], temp.size());
    std::cout << k.getHash() << std::endl;
    std::cout << k.getHash() << std::endl;
    std::cout << k.getHash() << std::endl;

    return 0;
}

returns

47173285a8d7341e5e972fc677286384f802f8ef42a5ec5f03bbfa254cb01fad
c82cad59277af8d880d6ccbbddf0bbed8359fdfaa7491960e1f2397011bf5ae5
d165ecff4927241ce0fa7184b3ad53b4116f7fea6a8b2e1f509e75d087bcfead

License mismatch

The LICENSE file in the repository describes a Zlib license, but the license inside the actual source code is maximally restrictive. When the author reserves all rights, it means that nobody can use the code in any way, not for commercial use, not for personal. They can't modify it or redistribute.

Consider copy-pasting contents of LICENSE into all source files.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.