title: PHP MCRYPT encrypt/decrypt returns invisible strange characters?
body: <p><code>mcrypt_decrypt</code> is giving me additional invisible characters which are NOT VISIBLE by just echoing out on the page. Can ONLY BE SEEN by writing it to the text file. Means, just displaying on the page is OK and hard to be noticed.</p>
  
  <p>Here is the code sample by Googling. <strong>Please guide me what is the correct usage is there's something wrong</strong>:</p>
  
  <pre><code>function encrypt ($pure_string, $key) {
      $iv_size = mcrypt_get_iv_size(MCRYPT_BLOWFISH, MCRYPT_MODE_ECB);
      $iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);
      $encrypted_string = mcrypt_encrypt(MCRYPT_BLOWFISH, $encryption_key, $pure_string, MCRYPT_MODE_ECB, $iv);
      return $encrypted_string;
  }
  
  function decrypt ($encrypted_string, $key) {
      $iv_size = mcrypt_get_iv_size(MCRYPT_BLOWFISH, MCRYPT_MODE_ECB);
      $iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);
      $decrypted_string = mcrypt_decrypt(MCRYPT_BLOWFISH, $encryption_key, $encrypted_string, MCRYPT_MODE_ECB, $iv);
      return $decrypted_string;
  }
  </code></pre>
  
  <p>but when i try it:</p>
  
  <pre><code>$encrypted_string = encrypt("This is the original string.", "ABC123");
  echo decrypt($encrypted_string, "ABC123");
  </code></pre>
  
  <p>.. i am getting something like:</p>
  
  <pre><code>This is the original string.�������
  </code></pre>
  
  <p>This strange characters <code>�������</code> are <strong>actually not visible when</strong> you/ i just <code>echo</code> it. Can only be seen by writing into the text file.</p>
  
  <ul>
  <li>So what am i missing please?</li>
  <li>Is there any perfect way to achieve this encrypt/decrypt?</li>
  </ul>
  
  <p>Thank you.</p>