title: mcrypt encrypt adding s bunch of '%00' to end of string
body: <p>Working with OAuth and encrypting the keys with the following function with a string which we'll call 'foo' (actually an OAuth token)</p>
  
  <pre><code>public function encrypt( $text )
  {
      // add end of text delimiter
      $data = mcrypt_encrypt( MCRYPT_RIJNDAEL_128, $this-&gt;key, $text, MCRYPT_MODE_ECB, $this-&gt;iv );
      return base64_encode( $data );
  }
  </code></pre>
  
  <p>When I decrypt it using the inverse function, I end up with:</p>
  
  <p><strong>Function:</strong></p>
  
  <pre><code>    public function decrypt( $text )
      {
          $text = base64_decode( $text );
          return mcrypt_decrypt( MCRYPT_RIJNDAEL_128, $this-&gt;key, $text, MCRYPT_MODE_ECB, $this-&gt;iv );
      }
  </code></pre>
  
  <p><strong>Result:</strong></p>
  
  <p><code>foo%00%00%00%00%00%00%00%00%00%00%00%00%00%00</code></p>
  
  <p><strong>Edit:</strong></p>
  
  <p>Looking at it a little more, I realized that it is actually URL encoding to %00, which means that my strings are somehow being padded by null characters? So I am currently using trim() to get rid of them, but I would like to understand why this is happening.</p>