c++创建空字节
C++ create empty byte
我想知道您是否可以帮助我解决一个小问题:
我目前正在c++/Qt中开发,并得到以下错误信息:
P:ProduktSavor_V100webapi.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
函数中的参数没有使用,因此我想在那里传递一个空字节。经过一番研究,我发现字节只是一个简单的无符号char?
我的代码是这样的:
byte* unused;
qDebug() << CryptoPP::PasswordBasedKeyDerivationFunction::DeriveKey(CryptoPP::SHA1::StaticAlgorithmName(), CryptoPP::SHA1::BLOCKSIZE, unused, user->getPassword(), sizeof(user->getPassword()), user->getSerial(), sizeof(user->getSerial()), 0 );
正如评论中所说,这里的问题是函数的第一个参数,而不是您使用unused
的第三个参数。由于我猜您确实需要这个参数,您应该按照建议尝试:
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 );
相关文章:
- 从 UTF-8 字节数组创建字符串?
- 当注入程序的内存空间时,如何读取从 0 到 0xFFFFFFFFF 的每个字节?我正在创建模式扫描仪
- 在编译时而不是运行时创建一个由两个字节组成的值
- 用FWRITE创建图像后,将交换字节
- 在内存(C 和/或 C++)中创建和管理字节缓冲区,该缓冲区可以根据需要自动调整大小
- 如何创建 std::vector of char/std::byte,其中第一个字节对齐到 16 个字节,但没有填充
- 根据C++代码在 PHP 中创建字节数据并将其传递给套接字
- 有可能在c++中创建一个占用不到一个字节内存的类型吗
- 如何创建代码隔离大小应该是16 mb(字节码)大小的c ++程序
- SWIG-为具有四个参数的函数创建一个类型映射,该参数传递一个字节数组
- 创建一个4字节的Char
- C++ - 创建位和半字节的整数
- 如何从字节 (DCMTK) 创建 DICOM 映像
- 动态创建字节数组后,监视中的符号数量意外
- 如何创建自定义字节级数据类型
- 有没有办法创建一个可以作为参数传递的 16 字节对齐类
- 创建未知长度的字节/字符数组
- 如何在C++中创建一个返回字节数组的函数?Arduino项目
- 在C++中创建一个字节[][],并使用JNI将其返回给Java
- 创建垫子后,从字节向量将图像加载到垫子上