Commit 624fc1ce by 高晓磊

添加获取32位md5hash值的方法

parent f682dcb2
......@@ -140,6 +140,42 @@ public class Digests {
return DigestUtils.md5DigestAsHex(input);
}
/**
*
* @param plainText
* 明文
* @return 32位密文
*/
public static String md5encryption(String plainText) {
String re_md5 = "";
try {
MessageDigest md = MessageDigest.getInstance("MD5");
md.update(plainText.getBytes());
byte b[] = md.digest();
int i;
StringBuilder buf = new StringBuilder("");
for (byte value : b) {
i = value;
if (i < 0) {
i += 256;
}
if (i < 16) {
buf.append("0");
}
buf.append(Integer.toHexString(i));
}
re_md5 = buf.toString();
} catch (Exception e) {
e.printStackTrace();
}
return re_md5;
}
/**
* base64编码
*/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment