title: OpenSSL AES256 cbc encrypt
body: <p>I tried to find a proper example on the Internet for days but did not succeed. I try to encrypt simple string (Hello World) with a key, then to decrypt the result.
  However the decrypted result has nothing to do with the original text. Can anyone point me to a direction please?</p>
  
  <p>The code I made:</p>
  
  <pre><code>AES_KEY aes_decryptKey;
  AES_KEY aes_encryptKey;
  
  const unsigned char mykey[] = {0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa};
  unsigned char encrypted ;
  unsigned char iv[] = {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};    
  unsigned char decrypted;
  
  AES_set_encrypt_key(mykey, 256, &amp;aes_encryptKey);
  AES_set_decrypt_key(mykey, 256, &amp;aes_decryptKey);
  
  const unsigned char original[]  = {0x48,0x65,0x6c,0x6c,0x6f,0x2c,0x77,0x6f,0x72,0x6c,0x64,0x21};
  
  AES_cbc_encrypt(original, &amp;encrypted, sizeof(original), &amp;aes_encryptKey, iv, 0);
  
  AES_decrypt( &amp;encrypted, &amp;decrypted, &amp;aes_decryptKey);
  
  NSLog(@"ORIGINAL: \"%s\"\n",original);
  NSLog(@"ENCRYPTED: \"%s\"\n",&amp;encrypted);
  NSLog(@"DECRYPTED: \"%s\"\n",&amp;decrypted);
  </code></pre>