title: Why openssl can't decode the string encoded by base64_encode function of php?
body: <p>I want to base64 encode a string, and decode it in C language with <code>OpenSSL</code> api.
  I encoded in <code>php</code> like that:</p>
  
  <pre><code>&lt;?php 
  echo base64_encode("aaa");
  ?&gt;
  
  result is "YWFh"
  </code></pre>
  
  <p>Then decode it in <code>C</code> like that:</p>
  
  <pre><code>int base64_decode(char *str,int str_len,char *decode,int decode_buffer_len){
      int len=0;
      BIO *b64,*bmem;
      b64=BIO_new(BIO_f_base64());
      bmem=BIO_new_mem_buf(str,str_len);
      bmem=BIO_push(b64,bmem);
      len=BIO_read(bmem,decode,str_len);
      decode[len]=0;
      BIO_free_all(bmem);
      return 0;
  }
  
  result is NULL, nothing decoded.
  </code></pre>
  
  <p>Can't decode the string encoded before.</p>
  
  <p>I tried to use these command lines to test:</p>
  
  <pre><code>$echo "aaa" | openssl enc -base64 
  output: YWFhCg==
  
  $echo "YWFhCg==" | openssl enc -base64 -d
  output: aaa
  </code></pre>
  
  <p>What's the difference between base64_encode in <code>php</code> and <code>openssl</code>?What causes this?</p>