lmw
2023-04-03 16ea883d3c03fd8b910f9282aa1bc08378d40d54
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
package cn.sinata.xldutils.utils;
 
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
/**
 * MD5加密
 * @author Administrator
 *
 */
public class Md5 {
    public static String getMd5Value(String sSecret)
 
    {
 
        try {
 
            MessageDigest bmd5 = MessageDigest.getInstance("MD5");
 
            bmd5.update(sSecret.getBytes());
 
            int i;
 
            StringBuffer buf = new StringBuffer();
 
            byte[] b = bmd5.digest();
 
            for(int offset = 0; offset < b.length; offset++)
 
            {
 
                i = b[offset];
 
                if(i < 0)
 
                    i += 256;
 
                if(i < 16)
 
                    buf.append("0");
 
                buf.append(Integer.toHexString(i));
 
            }
 
            return buf.toString();
 
        } catch (NoSuchAlgorithmException e) {
            e.printStackTrace();
        }
 
        return "";
 
    }
}