MD5 and SHA1 C++ hashing library

ε祈祈猫儿з 提交于 2019-11-27 06:07:49

问题


I'm trying to find a good (and well documented) hashing library to use with my C++ program, I only need to generate two hashes from a string.

I've tried with crypto++ and mhash and I didn't manage to make them work, also with http://www.zedwood.com/article/121/cpp-md5-function

I would be glad if this library is cross-platform.


回答1:


Try this open source library http://hashlib2plus.sourceforge.net/




回答2:


Search before ask, there is already question: What is the best encryption library in C/C++?

Solutions like OpenSSL and Crypto++ are cross-platform, if you "didn't manage to make them work", you should have been more specific like: I use OS xyz version xyz, compiler xyz version xyz, IDE xyz version xyz, trying to get work library xyz version xyz from http://xyz, and it does not work, because xyz errors.




回答3:


see my answer here. The original sample is taken from here, and operates on std::string rather than on std::istream. There are many good samples on cryptopp wiki, I'll try to look for some I used.

here's a sample from my code:

#include <cryptopp/md5.h>

byte digest[AES::BLOCKSIZE];
MD5().CalculateDigest(digest, (byte*)input.data(), input.size());

Here's the list of cryptopp samples on their wiki. Look at HashFunctions and HashFilter.



来源:https://stackoverflow.com/questions/4678447/md5-and-sha1-c-hashing-library

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!