首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >调试断言失败

调试断言失败
EN

Stack Overflow用户
提问于 2014-01-21 15:05:07
回答 1查看 1.9K关注 0票数 1

我是Crypto++的新手,我需要用字符串和in (调用散列函数和MAC函数)进行一些操作。

我看到了这个使用Crypto++生成SHA1随机散列,并试图跟随它。

我做了一个新的项目,编译了密码,将它们链接起来(我认为是正确的,因为没有链接器错误)。它建造得很好,但当我从main回来的时候,我有这样的想法:

调试断言失败!.blablabla/dbgdel.cpp第52行 表达:_Block_Type_Is_Valid(pHead->nBlockUse)

我在评论中和那些帖子一样,所以我不明白,为什么会发生这种事。

代码(包括就像地址一样,因为我真的很懒得在链接器上做好链接):

代码语言:javascript
复制
#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))));
}
EN

回答 1

Stack Overflow用户

发布于 2014-01-25 01:45:52

代码语言:javascript
复制
DEBUG ASSERTION FAILED! ...blablabla/dbgdel.cpp Line 52

Expression: _Block_Type_Is_Valid(pHead->nBlockUse) ...

这是来自Visual,而不是Crypto++。你的记忆力有问题。

代码语言:javascript
复制
$ 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;
}

对我来说很好:

代码语言:javascript
复制
$ ./t.exe
F7FF9E8B7BB2E09B70935A5D785E0CC5D9D0ABF0
$ 

我怀疑这里缺少一些信息,比如您正在处理您提到的字符串和ints (但没有向我们展示)。

你需要给我们看看你想要运行的代码。

我做了一个新的项目,编译了密码,将它们链接起来(我认为是正确的,因为没有链接器错误)。

您还可以验证您的项目是否按照Visual的预期设置。有关这一点,请参见将Crypto++编译并集成到MicrosoftVisualC++环境中

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/21261764

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档