title: How can I do this same encrypt/decrypt PHP function on iOS with Objective-C?
body: <p>I have a function in PHP that encrypts and decrypts strings:</p>
  
  <pre><code>function encrypt_decrypt($action, $string) 
  {
     $output = false;
     $key = 'mykeyhereblah';
     $iv = md5(md5($key));
     if( $action == 'encrypt' ) {
         $output = mcrypt_encrypt(MCRYPT_RIJNDAEL_256, md5($key), $string, MCRYPT_MODE_CBC, $iv);
         $output = base64_encode($output);
     }
     else if( $action == 'decrypt' ){
         $output = mcrypt_decrypt(MCRYPT_RIJNDAEL_256, md5($key), base64_decode($string), MCRYPT_MODE_CBC, $iv);
         $output = rtrim($output, "");
     }
     return $output;
  }
  </code></pre>
  
  <p>and I call it like this:</p>
  
  <pre><code>echo encrypt_decrypt('decrypt', '2Fa9cICuUFa/UnmAAa5FjXZK4ht9q3cN2qgk1pCvDSs=');
  </code></pre>
  
  <p>How can I do this exact same thing on iOS with Objective-C for an <code>NSString</code>? It needs to be compatible with this PHP function.</p>