/**
* MD5
*
* @author liu
*
*/
public class MD5 {
/**
* 使用MD5对原文进行加�?
*
* @param value
* 原文
* @return MD5加密�?
*/
public static String digest(String value) {
StringBuilder sb = null;
try {
MessageDigest digest = MessageDigest.getInstance("MD5");
byte[] result = digest.digest(value.getBytes());
sb = new StringBuilder();
for (byte b : result) {
String hexString = Integer.toHexString(b & 0xFF);
if (hexString.length() == 1) {
sb.append("0" + hexString);// 0~F
} else {
sb.append(hexString);
}
}
} catch (NoSuchAlgorithmException e) {
throw new RuntimeException(e);
}
return sb.toString();
}
}
MD5加密
最新推荐文章于 2023-07-31 08:50:00 发布