Here you can find the source of sha256(String raw)
public static String sha256(String raw)
//package com.java2s; //License from project: Open Source License import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; public class Main { public static String sha256(String raw) { return digest(raw, "SHA-256"); }// w w w . ja va 2s. com private static String digest(String raw, String algorithm) { if (raw == null || "".equals(raw)) return ""; MessageDigest md; try { md = MessageDigest.getInstance(algorithm); } catch (NoSuchAlgorithmException e) { throw new RuntimeException(e); } md.update(raw.getBytes()); StringBuilder sb = new StringBuilder(); for (byte b : md.digest()) { String hex = String.format("%02x", b); sb.append(hex); } return sb.toString(); } }