/**
* md5加密
*
* @param source 数据源,用于账号密码加密,username+password
* @return 加密字符串
*/
public static String MD5encode(String source) {
if (StringUtils.isBlank(source)) {
return null;
}
MessageDigest messageDigest = null;
try {
messageDigest = MessageDigest.getInstance("MD5");
} catch (NoSuchAlgorithmException ignored) {
}
byte[] encode = messageDigest.digest(source.getBytes());
StringBuilder hexString = new StringBuilder();
for (byte anEncode : encode) {
String hex = Integer.toHexString(0xff & anEncode);
if (hex.length() == 1) {
hexString.append('0');
}
hexString.append(hex);
}
return hexString.toString();
}
md5 加密
最新推荐文章于 2024-08-03 10:07:50 发布