Descriptografando o arquivo em C ++, que foi criptografado com o openssl -aes-128-cbc

Eu estou tentando descriptografar um arquivo em C ++. Este arquivo é criptografado com o seguinte comando:

openssl enc -nosalt -aes-128-cbc -pass pass:test -in "test.txt" -out "test_enc.txt" -p

O console mostra okey=098F6BCD4621D373CADE4E832627B4F6 eiv=0A9172716AE6428409885B8B829CCB05.

Em C ++ eu incluí o#include openssl/aes.h linha e tente descriptografar com o seguinte código:

const char *indata = string.toAscii().constData();

unsigned char outdata[strlen(indata)];

unsigned char ckey[] = "098F6BCD4621D373CADE4E832627B4F6";
    unsigned char ivec[] = "0A9172716AE6428409885B8B829CCB05";

    /* data structure that contains the key itself */
    AES_KEY key;

    /* set the encryption key */
    AES_set_decrypt_key(ckey, 256, &key);

    AES_cbc_encrypt((unsigned char*) indata, outdata, strlen(indata), &key, ivec, AES_DECRYPT);

    QString result = QString((const char*) outdata);

    return result;

A variável outdata contém um valor diferente do que antes da criptografia com o OpenSSL.

questionAnswers(2)

yourAnswerToTheQuestion