title: SHA-256 hashing yields the wrong result in Android
body: <p>I am trying to encrypt <code>12345</code> using <code>1111</code> as salt using <code>SHA-256</code> encoding and the answer I get is: <code>010def5ed854d162aa19309479f3ca44dc7563232ff072d1c87bd85943d0e930</code>
  which is not same as the value returned by <a href="http://hash.online-convert.com/sha256-generator" rel="nofollow">this site</a>.</p>
  
  <p>Here's the code snippet:</p>
  
  <pre><code>public String getHashValue(String entity, String salt){
      byte[] hashValue = null;
      try {
          MessageDigest digest =  MessageDigest.getInstance("SHA-256");
          digest.update(entity.getBytes("UTF-8"));
          digest.update(salt.getBytes("UTF-8"));
          hashValue = digest.digest();
      } catch (NoSuchAlgorithmException e) {
          Log.i(TAG, "Exception "+e.getMessage());
      } catch (UnsupportedEncodingException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
      }
      return BasicUtil.byteArrayToHexString(hashValue);
  }
  </code></pre>
  
  <p>I have verified my printing method with a sample from SO and result is fine. Can someone tell me what's wrong here?</p>
  
  <p>And just to clarify - when I encrypt same value &amp; salt in iOS code, the returned value is same as the value given by the converting site.</p>