1
我想知道你能不能幫我一個小問題空字節我有:c + +創建
我目前發民在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);
你可以通過'0',或者'nullptr'因爲參數類型是'字節*'。或者嘗試'reinterpret_cast(CryptoPP :: SHA1 :: StaticAlgorithmName())' –
perreal
你的問題是什麼? – Aravind