Here you can find the source of digest(byte[] data, String algorithm)
private static String digest(byte[] data, String algorithm)
//package com.java2s; //License from project: Apache License import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; public class Main { private static String digest(byte[] data, String algorithm) { try {/*ww w. ja va 2s . com*/ MessageDigest md = MessageDigest.getInstance(algorithm); byte[] digest = md.digest(data); StringBuilder buf = new StringBuilder(); for (byte b : digest) { buf.append(Integer.toHexString(0xF & (b >> 4))); buf.append(Integer.toHexString(0xF & (b))); } return buf.toString(); } catch (NoSuchAlgorithmException e) { throw new IllegalArgumentException(e); } } }