1

I'm new in Crypto++, and I need to make some manipulations with my strings and ints (call a hash function and MAC function)

I saw this Using Crypto++ to generate random hashes with SHA1 and tried to follow it.

I made new project, compiled cryptolibs, linked them (I think, correctly, because there is no linker errors). It built good, but on return from main I have this:

DEBUG ASSERTION FAILED! ...blablabla/dbgdel.cpp Line 52

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

I made it like at those post in comments, so i don't understand, why it happens.

code (includes are like addresses because i was really lazy to make good links at linker):

#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))));
}
Community
  • 1
  • 1
Viktor Fridman
  • 57
  • 2
  • 10

1 Answers1

1
DEBUG ASSERTION FAILED! ...blablabla/dbgdel.cpp Line 52

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

That's coming from Visual Studio, not Crypto++. You have a memory problem.


$ 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;
}

Runs fine for me:

$ ./t.exe
F7FF9E8B7BB2E09B70935A5D785E0CC5D9D0ABF0
$ 

I suspect there's some information missing - like what you are doing with your strings and ints you mentioned (but did not show us).

You need to show us the code you are trying to run.


I made new project, compiled cryptolibs, linked them (I think, correctly, because there is no linker errors).

You might also verify your projects is set up as expected for Visual Studio. For that see Compiling and Integrating Crypto++ into the Microsoft Visual C++ Environment.

jww
  • 97,681
  • 90
  • 411
  • 885