title: How can I calculate the SHA-256 hash of a string with a secret key in Android?
body: <p>I need to calculate a SHA-256 hash of a string with a secret key. I found this code :</p>
  
  <pre><code>public String computeHash(String input)
      throws NoSuchAlgorithmException, UnsupportedEncodingException
  {
      MessageDigest digest = MessageDigest.getInstance("SHA-256");
      digest.reset();
  
      byte[] byteData = digest.digest(input.getBytes("UTF-8"));
      StringBuffer sb = new StringBuffer();
  
      for (int i = 0; i &lt; byteData.length; i++) {
          sb.append(Integer.toString((byteData[i] &amp; 0xff) + 0x100, 16).substring(1));
      }
      return sb.toString();
  }
  </code></pre>
  
  <p>for calculating the hash without the secret key. How can I calculate with a secret key? I searched but I didn't find any solution in Android. Any idea ?</p>