我有功能解码AES 256字符串,但它仅返回16字符AES ECB加密/解密只解密前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](https://wiki.openssl.org/index.php/EVP_Symmetric_Encryption_and_Decryption)。事实上,您应该使用经过身份验证的加密,因为它提供了*机密性和真实性。请参阅OpenSSL wiki上的[EVP Authenticated Encryption and Decryption](https://wiki.openssl.org/index.php/EVP_Authenticated_Encryption_and_Decryption)。 – jww 2015-05-15 20:45:51