title: Encoding/decoding of data between PHP/Java for Android
body: <p>I have to decode a base64 encoded data received from a PHP server. </p>
  
  <p>The server uses 'base64_encode' to encode the data.</p>
  
  <p>In my Android app, I use android.utils.Base64 class to do the decoding.</p>
  
  <p>original encrypted data = "†+Ü]M(‡=ñö"<br>
  Base64 encoding data in PHP gives - "hisP3F1NBCgIAocQCD3x9g=="<br>
  Base64 encoding data in Android gives - "4oCgKw/DnF1NBCgIAuKAoRAIPcOxw7Y="  </p>
  
  <p>As you can see, the Java encoded string is longer than the PHP encoded string. I need to find out their default encoding formats. </p>
  
  <p>How to get the same encoded string from both?</p>
  
  <p>Java/Android code : </p>
  
  <pre><code>String encrypted = "†+Ü]M(‡=ñö";
  byte[] encoded = Base64.encode(encrypted.getBytes(), Base64.DEFAULT);
  String str = new String(encoded); //str = "4oCgKw/DnF1NBCgIAuKAoRAIPcOxw7Y="  
  </code></pre>