2009-02-23 14:58:00
public String makeMD5(String password) {
MessageDigest md;
try {
// 生成一个MD5加密计算摘要
md = MessageDigest.getInstance("MD5");
// 计算md5函数
md.update(password.getBytes());
// digest()最后确定返回md5 hash值,返回值为8为字符串。因为md5 hash值是16位的hex值,实际上就是8位的字符
// BigInteger函数则将8位的字符串转换成16位hex值,用字符串来表示;得到字符串形式的hash值
String pwd = new BigInteger(1, md.digest()).toString(16);
System.err.println(pwd);
return pwd;
} catch (Exception e) {
e.printStackTrace();
}
return password;
}
更多精彩内容:各种AI课程、技能课程、黑科技软件、网站小程序源码、副业小项目、PPT模板等精品素材、电商课程、推广引流课程等,尽在 天边资源网 。