hooyantsing's Blog

MD5_生成方法

字数统计: 97阅读时长: 1 min
2019/12/15

MD5 生成方法

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
public class HooyUtil {
       //盐,用于混交md5
       private static final String slat =  "#ysw#fsb&lym&hooy*2019";
       public static String getMD5(String  dataStr) {
           try {
               dataStr += slat;
               MessageDigest m =  MessageDigest.getInstance("MD5");
               m.update(dataStr.getBytes("UTF8"));
               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 "";
}
CATALOG