title: Java SHA256 outputs different hash to PHP SHA256?
body: <p>PHP code:</p>
  
  <p><code>echo hash('sha256', 'jake');</code></p>
  
  <p>PHP output:</p>
  
  <p>cdf30c6b345276278bedc7bcedd9d5582f5b8e0c1dd858f46ef4ea231f92731d</p>
  
  <p>Java code:</p>
  
  <pre><code>String s = "jake";
  MessageDigest md = MessageDigest.getInstance("SHA-256");
  md.update(s.getBytes(Charset.forName("UTF-8")));
  byte[] hashed = md.digest();
  String s2 = "";
  for (byte b : hashed) {
      s2 += b;
  }
  System.out.println(s2);
  </code></pre>
  
  <p>Java output:</p>
  
  <p>-51-1312107528211839-117-19-57-68-19-39-43884791-1141229-4088-12110-12-223531-11011529</p>
  
  <p>I had expected the two to return the same result. Obviously, this is not the case. How can I get the two to match up or is it impossible?</p>
  
  <p>EDIT: I had made a mistake, think I have the answer to the question now anyway.</p>