javaMD5加密
public static String getMD5Digest(String message) {
String digestResult = null;
try {
MessageDigest md5 = MessageDigest.getInstance("MD5");
byte[] temp;
temp = md5.digest(message.getBytes("UTF-8"));
StringBuffer sb = new StringBuffer();
for (int i = 0; i < buf.length; i++) {
String hex = Integer.toHexString(buf[i] & 0xFF);
if (hex.length() == 1) {
hex = '0' + hex;
}
sb.append(hex.toUpperCase());
}
digestResult = sb.toString();
} catch (NoSuchAlgorithmException e) {
LOGGER.error("Failed to get md5 instance!", e);
} catch (UnsupportedEncodingException e) {
LOGGER.error("Failed to encode utf-8 instance!", e);
}
return digestResult.toLowerCase();
}