title: How to encrypt with AES 256 CBC in Objective C
body: <p>I am building an iPhone app which gets a encrypt string and sent it to backend.</p>
  
  <p>In PHP I am encrypting the string like this:</p>
  
  <pre><code>$encrypt_method = "AES-256-CBC";
  $secret_key = 'This is my secret key';
  $secret_iv = 'This is my secret iv';
  
  // hash
  $key = hash('sha256', $secret_key);
  
  // iv - encrypt method AES-256-CBC expects 16 bytes - else you will get a warning
  $iv = substr(hash('sha256', $secret_iv), 0, 16);
  
  if( $action == 'encrypt' ) {
      $output = openssl_encrypt($string, $encrypt_method, $key, 0, $iv);
      $output = base64_encode($output);
  }
  </code></pre>
  
  <p>How I do the same like that but in Objective C</p>