Here you can find the source of sha256(String message)
public static byte[] sha256(String message) throws NoSuchAlgorithmException
//package com.java2s; //License from project: Open Source License import java.nio.charset.Charset; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; public class Main { private static final String ERROR_NULL_INPUT = "Input can't be null."; private static final String UTF8 = "UTF-8"; private static final String SHA256 = "SHA-256"; public static byte[] sha256(String message) throws NoSuchAlgorithmException { MessageDigest md = MessageDigest.getInstance(SHA256); return md.digest(stringToBytes(message)); }// w w w . j a v a 2s . c o m public static byte[] stringToBytes(String input) { if (input == null) { throw new IllegalArgumentException(ERROR_NULL_INPUT); } return input.getBytes(Charset.forName(UTF8)); } }