Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/qt/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ C++;创建空字节_C++_Qt - Fatal编程技术网

C++ C++;创建空字节

C++ C++;创建空字节,c++,qt,C++,Qt,我想知道你是否能帮我解决我的一个小问题: 我目前正在使用C++/Qt进行开发,并收到以下错误消息: P:\Produkt\Savor_V100\webapi.cpp:84: error: C2664: 'CryptoPP::PasswordBasedKeyDerivationFunction::DeriveKey' : cannot convert parameter 1 from 'const char *' to 'byte *' Types pointed to are unrelated

我想知道你是否能帮我解决我的一个小问题:

我目前正在使用C++/Qt进行开发,并收到以下错误消息:

P:\Produkt\Savor_V100\webapi.cpp:84: error: C2664: 'CryptoPP::PasswordBasedKeyDerivationFunction::DeriveKey' : cannot convert parameter 1 from 'const char *' to 'byte *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
函数中的参数未使用,因此我想在其中传递一个空字节。经过一点研究,我发现一个字节只是一个简单的无符号字符

我的代码如下所示:

byte* unused;
qDebug() << CryptoPP::PasswordBasedKeyDerivationFunction::DeriveKey(CryptoPP::SHA1::StaticAlgorithmName(), CryptoPP::SHA1::BLOCKSIZE,  unused, user->getPassword(), sizeof(user->getPassword()), user->getSerial(), sizeof(user->getSerial()), 0 );
byte*未使用;
qDebug()getPassword(),sizeof(用户->getPassword()),用户->getSerial(),sizeof(用户->getSerial()),0);

如评论中所述,这里的问题是函数的第一个参数,而不是使用
未使用的
的第三个参数。因为我想您确实需要这个参数,所以您应该按照建议尝试:

qDebug() << CryptoPP::PasswordBasedKeyDerivationFunction::DeriveKey(
              reinterpret_cast<byte*>(CryptoPP::SHA1::StaticAlgorithmName()),
              CryptoPP::SHA1::BLOCKSIZE,
              0,
              user->getPassword(),
              sizeof(user->getPassword()), 
              user->getSerial(), 
              sizeof(user->getSerial()), 
              0 );
qDebug()获取密码(),
sizeof(用户->获取密码()),
用户->getSerial(),
sizeof(用户->getSerial()),
0 );

您可以传递
0
,或者
nullptr
,因为参数类型是
byte*
。或者尝试重新解释(CryptoPP::SHA1::StaticAlgorithmName())
您的问题是什么?