通过java语言实现MD5加密

通过java语言实现MD5加密
public static String getMd5(String str) {
try {
MessageDigest md5 = MessageDigest.getInstance("MD5");
byte[] bytes = md5.digest(str.getBytes());
String temp, result = "";
for (byte b : bytes) {
temp = Integer.toHexString(b & 0xff);
if (temp.length() == 1) {
temp = "0" + temp;
}
result = result + temp;
}
return result;
} catch (Exception e) {
e.printStackTrace();
}
return "";
}

猜你喜欢

转载自www.cnblogs.com/lucl/p/12201878.html