Here you can find the source of sha256(String text)
public static final String sha256(String text) throws NoSuchAlgorithmException
//package com.java2s; //License from project: Open Source License import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; public class Main { public static final String sha256(String text) throws NoSuchAlgorithmException { MessageDigest md = MessageDigest.getInstance("SHA-256"); return toHex(md.digest(text.getBytes())); }/*from ww w. j a v a 2 s . co m*/ public static final String toHex(byte data[]) { char[] hex = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f', }; StringBuffer result = new StringBuffer(data.length * 2); for (int i = 0; i < data.length; i++) { result.append(hex[(data[i] >> 4) & 0x0f]).append(hex[data[i] & 0x0f]); } return result.toString(); } }