Here you can find the source of SHA256(byte[] P)
public static String SHA256(byte[] P)
//package com.java2s; //License from project: Open Source License import java.security.MessageDigest; public class Main { public static String SHA256(byte[] P) { try {// w w w. j av a 2 s . c o m MessageDigest SIG = MessageDigest.getInstance("SHA-256"); SIG.update(P, 0, P.length); byte D[] = SIG.digest(); return getHexString(D); } catch (java.security.NoSuchAlgorithmException e) { throw new RuntimeException(e); } } public static String SHA256(String s) { return SHA256(s.getBytes()); } public static String getHexString(byte[] data) { StringBuilder sb = new StringBuilder(); for (byte b : data) { sb.append(String.format("%02x", b)); } return sb.toString(); } }