Here you can find the source of sha256(String data)
public static String sha256(String data) throws NoSuchAlgorithmException
//package com.java2s; //License from project: Open Source License import java.math.BigInteger; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; public class Main { public static String sha256(String data) throws NoSuchAlgorithmException { return byte2hex(MessageDigest.getInstance("SHA-256").digest(data.getBytes())); }/* w w w . j a va 2 s.c o m*/ public static String byte2hex(byte[] bytes) { BigInteger bi = new BigInteger(1, bytes); String hex = bi.toString(16); int paddingLength = (bytes.length * 2) - hex.length(); if (paddingLength > 0) { return String.format("%0" + paddingLength + "d", 0) + hex; } return hex; } }