public class MD5 {
public static String md5(String str){
if (TextUtils.isEmpty(str)){
return "";
}
MessageDigest md5=null;
try {
md5=MessageDigest.getInstance("MD5");
byte[] bytes=md5.digest(str.getBytes());
String result="";
for (byte b:bytes){
String temp=Integer.toHexString(b&0xff);
if (temp.length()==1){
temp="0"+temp;
}
result += temp;
}
return result;
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
}
return "";
}
}
网友评论