package com.svw.newsvwuc.common.utils;
import cn.hutool.core.util.StrUtil;
import java.nio.charset.StandardCharsets;
import java.security.MessageDigest;
/**
* <p>ClassName: MD5Util</p>
* <p>Description:Md5工具包</p>
* <p>Date: 2021/3/24</p>
*/
public class MD5Util {
/**
* <p> md5加密 </p>
*
* @param password :加密的内容
* @return : java.lang.String
* @date: 2021/3/24 12:53
**/
public static String md5(String password) {
if (StrUtil.isBlank(password)) {
return null;
} else {
String value = null;
MessageDigest md5 = null;
try {
md5 = MessageDigest.getInstance("MD5");
sun.misc.BASE64Encoder baseEncoder = new sun.misc.BASE64Encoder();
if (md5 != null) {
value = baseEncoder.encode(md5.digest(password.getBytes(StandardCharsets.UTF_8)));
}
} catch (Exception ex) {
return null;
}
return value;
}
}
}