Here you can find the source of digest(String raw, String algorithm)
private static String digest(String raw, String algorithm)
//package com.java2s; //License from project: Open Source License import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; public class Main { private static String digest(String raw, String algorithm) { if (raw == null || "".equals(raw)) return ""; MessageDigest md;/* w w w . j a v a 2 s. co m*/ 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(); } }