title: Converting base64 encoded bytes to string different in Java and C#
body: <p>I have some code to login to a 3rd party solution, that requires me to encode a password. They have provided me with a sample in Java, but I also need to develop it in C# (and PHP, later).</p>
  
  <p>I have the code in a C# Windows app, and a Java Android app, and with the same output, they seem to work well up until the point where I try and convert the cypher bytes to a base 64 encoded string.</p>
  
  <p>Here is the Java code:</p>
  
  <pre><code>enc = Base64.encodeBase64(ciphertext);
  return enc.toString();
  </code></pre>
  
  <p>And here is the C# code:</p>
  
  <pre><code>return System.Convert.ToBase64String(cipherBytes);
  </code></pre>
  
  <p>I can see that the ciphertext bytes in the Java app are the same as in the C# app, except that they are signed, and that the base64 encoded bytes in Java, if converted to ASCII values, would give the string that I am seeing in the C# app, but the enc.ToString() in Java is not returning that same string.</p>
  
  <h3>More info</h3>
  
  <p>Java</p>
  
  <pre><code>ciphertext = 66, 67, -69, 24, -48, -23, 84, -5
  encodeded64 = 81, 107, 79, 55, 71, 78, 68, 112, 86, 80, 115, 61
  to string = [B@41771ea8
  </code></pre>
  
  <p>C#</p>
  
  <pre><code>cipherBytes = 66, 67, 187, 24, 208, 233, 84, 251
  result = QkO7GNDpVPs=
  </code></pre>
  
  <p>Many thanks for your help. (This is my first post here, so please feel free to let me know if I broke any rules)</p>