Here you can find the source of md5(String... args)
public static String md5(String... args) throws Exception
//package com.java2s; //License from project: Apache License import java.security.MessageDigest; public class Main { private final static String CHARSET = "UTF-8"; private final static String SEPARATOR = "$"; public static String md5(String... args) throws Exception { String tmp = joinStrings(args); MessageDigest messageDigest = MessageDigest.getInstance("MD5"); messageDigest.reset();// ww w .j a v a 2 s.c o m messageDigest.update(tmp.getBytes(CHARSET)); byte[] byteArray = messageDigest.digest(); StringBuffer md5StrBuff = new StringBuffer(); for (int i = 0; i < byteArray.length; i++) { if (Integer.toHexString(0xFF & byteArray[i]).length() == 1) { md5StrBuff.append("0").append( Integer.toHexString(0xFF & byteArray[i])); } else { md5StrBuff.append(Integer.toHexString(0xFF & byteArray[i])); } } return md5StrBuff.toString(); } private static String joinStrings(String... array) { StringBuilder sb = new StringBuilder(); for (int i = 0; i < array.length; i++) { sb.append(array[i]); if (i < array.length - 1) { sb.append(SEPARATOR); } } return sb.toString(); } }