Here you can find the source of sha256(String string)
public static byte[] sha256(String string)
//package com.java2s; //License from project: Open Source License import java.nio.charset.StandardCharsets; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; public class Main { public static byte[] sha256(String string) { MessageDigest digest;//from w w w . ja v a 2s. c om try { digest = MessageDigest.getInstance("SHA-256"); } catch (NoSuchAlgorithmException ex) { throw new RuntimeException(ex.getMessage(), ex); } return digest.digest(string.getBytes(StandardCharsets.UTF_8)); } }