Here you can find the source of digest(String base)
public static String digest(String base)
//package com.java2s; //License from project: LGPL import java.nio.charset.StandardCharsets; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; public class Main { public static String digest(String base) { MessageDigest digest = defaultMessageDigest(); byte[] hash = digest.digest(base.getBytes(StandardCharsets.UTF_8)); return bytesToHexString(hash); }/* w ww .j a v a2 s .c o m*/ public static MessageDigest defaultMessageDigest() { try { return MessageDigest.getInstance("SHA-256"); } catch (NoSuchAlgorithmException e) { throw new RuntimeException(e); } } public static String bytesToHexString(byte[] bytes) { StringBuilder hexString = new StringBuilder(); for (byte aHash : bytes) { String hex = Integer.toHexString(0xff & aHash); if (hex.length() == 1) hexString.append('0'); hexString.append(hex); } return hexString.toString(); } }