public static String md5(String message){
MessageDigest md =MessageDigest.getInstance("md5");
byte[] b=md. digest(message.getBytes());
BASE64Encode encode=new BASE64Encode();
return encode.encode(md5);
}
public static String getMD5(String str){
MessageDigest digest;
StringBuffer buf = new StringBuffer("");
try {
digest = MessageDigest.getInstance("md5");
byte[] b=digest.digest(str.getBytes());
int i;
for (int offset = 0; offset < b.length; offset++) {
i = b[offset];
if(i<0) i+= 256;
if(i<16)
buf.append("0");
buf.append(Integer.toHexString(i));
//return buf.toString();//32 位加密
//return buf.toString.subString(8,24);//16 位加密
}
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
}
return buf.toString();
}