Here you can find the source of digest(String value, String algorithm)
private static byte[] digest(String value, String algorithm)
//package com.java2s; //License from project: Apache License import java.io.UnsupportedEncodingException; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; public class Main { private final static String CHARSET = "UTF-8"; private static byte[] digest(String value, String algorithm) { if (value == null || "".equals(value.trim())) { return null; }//ww w . ja va2 s .c o m byte[] bytes = null; try { MessageDigest md = MessageDigest.getInstance(algorithm); bytes = md.digest(value.getBytes(CHARSET)); } catch (NoSuchAlgorithmException e) { //NOP } catch (UnsupportedEncodingException e) { //NOP } return bytes; } }