title: Encrypting strings in PHP
body: <p>Currently im using</p>
  
  <pre><code>$key="pass";
  $val="secret";
  $encp=mcrypt_encrypt(MCRYPT_DES, $key, $val, MCRYPT_MODE_ECB);
  </code></pre>
  
  <p>But when i call <code>printf($encp)</code>
  No value is displayed,im using PHP version 5.2.17</p>
  
  <p>Is there a better way to do it.Please help.</p>
  
  <p>EDIT:</p>
  
  <pre><code>&lt;?PHP
  
      define('SECURE_KEY','Somekey');
  
      function encrypt($value){
          $iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB);
          $iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);
          return mcrypt_encrypt(MCRYPT_RIJNDAEL_256, SECURE_KEY, $value, MCRYPT_MODE_ECB, $iv);
      }
  
      function decrypt($value){
          $iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB);
          $iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);
          return trim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, SECURE_KEY, $value, MCRYPT_MODE_ECB, $iv));
      }
      $temp=encrypt("teststring");
      printf($temp);
      ?&gt;
  </code></pre>