how to convert 'const char *' to '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);
}
the error got while compilation of the program
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,
I tried this doesn't work
std::string s(reinterpret_cast<const unsigned char *>(Data), Size);
uint8_t
, if it's available , is just a typedef to unsigned char
. Therefore, you can just do:
bool AES(const uint8_t *Data, size_t Size) {
AES_cbc_encrypt(Data, enc_out, Size, &enc_key, iv, AES_ENCRYPT);
}
Note that you should probably return something in your function as well.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.