我有一个解密AES 256字符串的函数,但它只返回16个字符。
bool decrypt_block(unsigned char* cipherText, unsigned char* plainText, unsigned char* key)
{
AES_KEY decKey;
if (AES_set_decrypt_key(key, 256, &decKey) < 0)
return false;
AES_decrypt(cipherText, plainText, &decKey);
return true;
}
decrypt_block( encoded, resultText, ( unsigned char *) "57f4dad48e7a4f7cd171c654226feb5a");
有什么想法吗?
AES_encrypt
和相关函数,而应该使用EVP_*
函数。请参考 OpenSSL wiki 上的 EVP Symmetric Encryption and Decryption。事实上,你应该使用认证加密,因为它提供了*机密性和真实性两个方面的保护。请参考 OpenSSL wiki 上的 EVP Authenticated Encryption and Decryption。 - jww