Here you can find the source of digest(String aValue)
public static String digest(String aValue)
//package com.java2s; //License from project: Apache License import java.io.UnsupportedEncodingException; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; public class Main { private static String encodingCharset = "UTF-8"; public static String digest(String aValue) { aValue = aValue.trim();//w ww. j av a 2 s . com byte[] value; try { value = aValue.getBytes(encodingCharset); } catch (UnsupportedEncodingException e) { value = aValue.getBytes(); } MessageDigest md = null; try { md = MessageDigest.getInstance("SHA"); } catch (NoSuchAlgorithmException e) { e.printStackTrace(); return null; } return toHex(md.digest(value)); } public static String toHex(byte[] input) { if (input == null) { return null; } StringBuffer output = new StringBuffer(input.length * 2); for (int i = 0; i < input.length; i++) { int current = input[i] & 0xFF; if (current < 16) { output.append("0"); } output.append(Integer.toString(current, 16)); } return output.toString(); } }