package com.chinacloudly.utils.md5;

import java.security.MessageDigest;

public class MD5Util {
	
	/*
	 * md5 a string
	 */
	public final static String MD5(String s) {
		char hexDigits[]={'0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f'};
		try {
			byte[] btInput = s.getBytes();
			MessageDigest mdInst = MessageDigest.getInstance("MD5");
			mdInst.update(btInput);
			byte[] md = mdInst.digest();
			int j = md.length;
            char str[] = new char[j * 2];
            int k = 0;
            for (int i = 0; i < j; i++) {
                byte byte0 = md[i];
                str[k++] = hexDigits[byte0 >>> 4 & 0xf];
                str[k++] = hexDigits[byte0 & 0xf];
            }
            return new String(str);
		} catch (Exception e) {
			e.printStackTrace();
            return null;
		}
	}
	
	/*
	 * md5 a string with salt
	 * md5(s + salt)
	 */
	public final static String saltMD5(String s, String salt) {
		return MD5(s + salt);
	}
}

@@ -93,32 +93,33 @@
 D5Util %7B%0D%0A%09%0D%0A%09/*
+*
 %0D%0A%09 * md5 a stri
@@ -120,16 +120,112 @@
 a string
+ %0D%0A%09 * Usage: saltMD5(sourceString)%0D%0A%09 * @param s sourceString%0D%0A%09 * @return MD5 String with salt
 %0D%0A%09 */%0D%0A
@@ -947,16 +947,17 @@
 %0D%0A%09%0D%0A%09/*
+*
 %0D%0A%09 * md
@@ -997,16 +997,151 @@
  salt)%0D%0A
+%09 * Usage: saltMD5(sourceString, saltString)%0D%0A%09 * @param s sourceString%0D%0A%09 * @param salt saltString%0D%0A%09 * @return MD5 String with salt%0D%0A
 %09 */%0D%0A%09p

add java docs