title: Im trying encrypt some text using a fucntion in php
body: <p>I found a tutorial online on how to encrypt strings in php but when I call the function and try echo the processed data I'm getting 500 internal error. Here is my code below.</p>
  
  <pre><code> &lt;?php
  
  
  
      $iv_to_pass_to_decryption = 'mysecretpass';
      function encrypt($text, $key)
      {
          $iv = mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_CBC), MCRYPT_RAND); 
          $iv_to_pass_to_decryption = base64_encode($iv);
          return base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $key, $text, MCRYPT_MODE_CBC, $iv); 
      }
  
  
  
  
      function decrypt($text, $key, $iv)
      { 
          $text = base64_decode($text);
          $iv = base64_decode($iv);
          return mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $key, $text, MCRYPT_MODE_CBC, $iv);
      }
  
  
      $txt = "hello";
      $mykey = "mysecretkey";
      $somedata = encrypt($txt, $mykey);
  
      echo $somedata;
  
  
  
  
      ?&gt;
  </code></pre>