-
编写MD5加密方法,dataStr为需要加密的字符串,一般加盐进行加密
// 加盐 private static final String slat = "appdemo"; public static String encrypt(String dataStr) { try { dataStr = dataStr + slat; MessageDigest m = MessageDigest.getInstance("MD5"); m.update(dataStr.getBytes("UTF-8")); byte s[] = m.digest(); String result = ""; for (int i = 0; i < s.length; i++) { result += Integer.toHexString((0x000000FF & s[i]) | 0xFFFFFF00).substring(6); } return result; } catch (Exception e) { e.printStackTrace(); } return ""; }
-
调用该方法传入参数进行加密即可
06-25
01-28
8874
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
06-13
2万+
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
06-29