我是Crypto++的新手,我需要用字符串和in (调用散列函数和MAC函数)进行一些操作。
我看到了这个使用Crypto++生成SHA1随机散列,并试图跟随它。
我做了一个新的项目,编译了密码,将它们链接起来(我认为是正确的,因为没有链接器错误)。它建造得很好,但当我从main回来的时候,我有这样的想法:
调试断言失败!.blablabla/dbgdel.cpp第52行 表达:_Block_Type_Is_Valid(pHead->nBlockUse)
我在评论中和那些帖子一样,所以我不明白,为什么会发生这种事。
代码(包括就像地址一样,因为我真的很懒得在链接器上做好链接):
#include <C:\Users\esselesse\Documents\Visual Studio 2010\Projects\InfoProtect_Biometrics_Auth_Algorithm\InfoProtect_Biometrics_Auth_Algorithm\LIB\sha.h>
#include <C:\Users\esselesse\Documents\Visual Studio 2010\Projects\InfoProtect_Biometrics_Auth_Algorithm\InfoProtect_Biometrics_Auth_Algorithm\LIB\filters.h>
#include <C:\Users\esselesse\Documents\Visual Studio 2010\Projects\InfoProtect_Biometrics_Auth_Algorithm\InfoProtect_Biometrics_Auth_Algorithm\LIB\hex.h>
#include <iostream>
#include <string>
using namespace CryptoPP;
using namespace std;
int main()
{
SHA1 sha1;
string source = "Hello"; //This will be randomly generated somehow
string hash = "";
StringSource(source, true, new HashFilter(sha1, new HexEncoder(new StringSink(hash))));
}发布于 2014-01-25 01:45:52
DEBUG ASSERTION FAILED! ...blablabla/dbgdel.cpp Line 52
Expression: _Block_Type_Is_Valid(pHead->nBlockUse) ...这是来自Visual,而不是Crypto++。你的记忆力有问题。
$ cat t.cpp
// g++ -I/usr/local/include t.cpp -o t.exe -lcryptopp -lpthread
#include <cryptopp/sha.h>
#include <cryptopp/filters.h>
#include <cryptopp/hex.h>
#include <iostream>
#include <string>
using namespace CryptoPP;
using namespace std;
int main()
{
SHA1 sha1;
string source = "Hello"; //This will be randomly generated somehow
string hash = "";
StringSource(source, true, new HashFilter(sha1, new HexEncoder(new StringSink(hash))));
cout << hash << endl;
return 0;
}对我来说很好:
$ ./t.exe
F7FF9E8B7BB2E09B70935A5D785E0CC5D9D0ABF0
$ 我怀疑这里缺少一些信息,比如您正在处理您提到的字符串和ints (但没有向我们展示)。
你需要给我们看看你想要运行的代码。
我做了一个新的项目,编译了密码,将它们链接起来(我认为是正确的,因为没有链接器错误)。
您还可以验证您的项目是否按照Visual的预期设置。有关这一点,请参见将Crypto++编译并集成到MicrosoftVisualC++环境中。
https://stackoverflow.com/questions/21261764
复制相似问题