I'm not sure, that this code is correct?
thx for help code: #include <stdio.h> #include <openssl/evp.h> int main(int argc, char *argv[]) { unsigned char text[]="Hello World!"; char key[]="password"; char iv[]="12345678"; unsigned char outbuf[1024]; int outlen, tmplen, i; EVP_CIPHER_CTX ctx; EVP_CIPHER_CTX_init(&ctx); EVP_EncryptInit_ex(&ctx,EVP_aes_256_cbc(),NULL,key,iv); EVP_EncryptUpdate(&ctx,outbuf,&outlen,text,strlen(text)); EVP_EncryptFinal_ex(&ctx,outbuf+outlen,&tmplen); outlen+=tmplen; EVP_CIPHER_CTX_cleanup(&ctx); printf("%s\n",outbuf); EVP_DecryptInit_ex(&ctx,EVP_aes_256_cbc(),NULL,key,iv); EVP_DecryptUpdate(&ctx,outbuf,&outlen,text,strlen(text)); EVP_DecryptFinal_ex(&ctx,outbuf+outlen,&tmplen); outlen+=tmplen; EVP_CIPHER_CTX_cleanup(&ctx); printf("%s\n",text); }