1
zj
2024-06-03 09206aedcfdf30050123e99f2af0a192ebad1de4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package com.nq.utils;
 
import java.math.BigInteger;
import java.security.MessageDigest;
 
public class Md5Utils {
    public static String getMD5(String str) throws Exception {
        try {
            MessageDigest md = MessageDigest.getInstance("MD5");
            md.update(str.getBytes());
            return (new BigInteger(1, md.digest())).toString(16);
        } catch (Exception e) {
            throw new Exception();
        }
    }
 
    public  static  String encrype(String input){
        try {
            MessageDigest md = MessageDigest.getInstance("MD5");
           byte[] digest =  md.digest(input.getBytes());
           StringBuffer sb = new StringBuffer();
           for (byte b :digest){
               sb.append(String.format("%02x",b&0xff));
 
           }
           return  sb.toString();
 
        }catch (Exception e){
 
            return  null;
        }
    }
 
 
    public static String md5_32(String plainText) throws Exception {
        String re_md5 = new String();
        try {
            MessageDigest md = MessageDigest.getInstance("MD5");
            md.update(plainText.getBytes());
            byte[] b = md.digest();
 
            StringBuffer buf = new StringBuffer("");
            for (int offset = 0; offset < b.length; offset++) {
                int i = b[offset];
                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;
    }
 
 
    public static void main(String[] args) throws Exception {
        System.out.println(md5_32("SLPNXGC157080458540512750000http://serverback.comhttp://serverback.comea40b08d39a043b882ab197c6c9c7699"));
    }
}