public class MD5 {
public static String getMd5(String source) {
try {
if(source==null||source.length()<1)
{
return null;
}
MessageDigest messageDigest = MessageDigest.getInstance("MD5");
byte[] b = messageDigest.digest(source.getBytes("utf-8"));
BASE64Encoder base64en = new BASE64Encoder();
return base64en.encode(b);
} catch (Exception e) {
throw new RuntimeException("not support md5");
}
}
public static void main(String args[])
{
System.out.println(MD5.getMd5("a"));
}
}