这是我调用该函数的地方..
memcpy(dataHashResult,sha1.operator()(dataBuffer,16),16);
我变了
///计算内存块的 SHA1
std::string operator()(const void* data, size_t numBytes);
至
std::string operator()(BYTE* data, size_t numBytes);
缓冲区的类型是..
unsigned char dataBuffer[64];
unsigned char dataHashResult[64];
任何帮助将不胜感激..我是 C++ 新手.. 谢谢。
最佳答案
试试这个:
memcpy(dataHashResult,sha1.operator()(dataBuffer,16).c_str(),16);
问题是 memcpy
需要一个从中复制的指针。您的原始代码为其提供了一个 std::string
对象。幸运的是,std::string
有一个 c_str()
函数,它返回“C 风格”字符串,即 const char*
。
关于c++ - c2664 无法将参数 2 从 'std::string' 转换为 'const void *',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33101913/