How do I generate a hash code with hash sha256 in java?
<p>I would like to know the code to do this in java please? </p>

<p>This is what i have so far but it does not work?</p>

<pre><code>import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import static jdk.nashorn.tools.ShellFunctions.input;

public class Sha256hash 
{

    public static String main(String[] args) throws NoSuchAlgorithmException 
    {
        MessageDigest md = MessageDigest.getInstance("SHA1");
            md.reset();
            byte[] buffer = input.getBytes("UTF-8");
            md.update(buffer);
            byte[] digest = md.digest();

            String hexStr = "";
            for (int i = 0; i &lt; digest.length; i++) {
                hexStr +=  Integer.toString( ( digest[i] &amp; 0xff ) + 0x100, 16).substring( 1 );
            }
            return hexStr;
    }

}
</code></pre>