如何将'const char *'转换为'const unsigned char *'
bool AES(const uint8_t *Data, size_t Size) {
std::string s(reinterpret_cast<const char *>(Data), Size);
AES_cbc_encrypt(s.c_str(), enc_out, Size, &enc_key, iv, AES_ENCRYPT);
}
编译程序时出错
candidate function not viable: no known conversion from 'const char *' to 'const unsigned char *'
for 1st argument
void AES_cbc_encrypt(const unsigned char *in, unsigned char *out,
我试过这不起作用
std::string s(reinterpret_cast<const unsigned char *>(Data), Size);
答案 0 :(得分:1)
uint8_t
,if it's available,只是unsigned char
的typedef。因此,您可以这样做:
bool AES(const uint8_t *Data, size_t Size) {
AES_cbc_encrypt(Data, enc_out, Size, &enc_key, iv, AES_ENCRYPT);
}
请注意,您也应该在函数中返回一些内容。