import com.library.base.util.StringUtil;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
/**
* MD5加密
* Created by PanX
*/
public class MD5Util {
public static String md5(String string) {
if (string.equals(null)) {
return "";
}
MessageDigest md5 = null;
try {
md5 = MessageDigest.getInstance("MD5");
byte[] bytes = md5.digest(string.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 "";
}
}
Android MD5加密工具类
最新推荐文章于 2024-04-27 16:14:47 发布