Here you can find the source of hexDigest(String input)
public static String hexDigest(String input) throws NoSuchAlgorithmException, UnsupportedEncodingException
//package com.java2s; import java.io.UnsupportedEncodingException; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.util.Formatter; public class Main { /** First encrypts with SHA1 and then spits the result out as a hex string*/ public static String hexDigest(String input) throws NoSuchAlgorithmException, UnsupportedEncodingException { return convertToHex(dataDigest(input)); }//from ww w . j av a2 s .c o m private static String convertToHex(byte[] in) { StringBuilder builder = new StringBuilder(in.length * 2); Formatter formatter = new Formatter(builder); for (byte inByte : in) formatter.format("%02x", inByte); formatter.close(); return formatter.toString(); } private static byte[] dataDigest(String in) throws NoSuchAlgorithmException, UnsupportedEncodingException { if (in == null) return null; MessageDigest md = MessageDigest.getInstance("SHA-1"); return md.digest(in.getBytes("UTF8")); } }