Here you can find the source of md5(byte[] source)
public static String md5(byte[] source)
//package com.java2s; //License from project: Apache License import java.io.UnsupportedEncodingException; import java.security.MessageDigest; public class Main { private static final String ALGORITHM = "MD5"; private static final String DEFAULT_CHARSET = "UTF-8"; private static char hexDigits[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' }; public static String md5(byte[] source) { try {/* w w w . j ava2 s .c om*/ MessageDigest messageDigest = MessageDigest.getInstance(ALGORITHM); messageDigest.update(source); byte[] digest = messageDigest.digest(); int j = digest.length; char str[] = new char[j * 2]; int k = 0; for (int i = 0; i < j; i++) { byte byte0 = digest[i]; str[k++] = hexDigits[byte0 >>> 4 & 0xf]; str[k++] = hexDigits[byte0 & 0xf]; } return new String(str); } catch (Exception e) { e.printStackTrace(); } return ""; } public static String md5(String text) { return md5(text, DEFAULT_CHARSET); } public static String md5(String str, String charset) { try { return md5(str.getBytes(charset)); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } return ""; } }