ludc
2023-07-28 6ddaebea3b9afa4a34500068a21203ea05ba5ad7
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
package com.vci.ubcs.starter.web.util;
 
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//
 
 
import java.security.MessageDigest;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
 
public class Md5 {
    private static Logger logger = LoggerFactory.getLogger(Md5.class);
 
    public Md5() {
    }
 
    public static String md5(String v) {
        if (v == null) {
            return null;
        } else {
            try {
                MessageDigest md = MessageDigest.getInstance("MD5");
                return toHex(md.digest(v.getBytes()));
            } catch (Exception var2) {
                return null;
            }
        }
    }
 
    public static String twoTimesMd5(String sourceString) throws Exception {
        return sourceString == null ? null : md5(md5(sourceString));
    }
 
    public static boolean equalMd5(String md5String, String sourceString) {
        if (md5String != null && sourceString != null) {
            try {
                return md5String.equals(twoTimesMd5(sourceString));
            } catch (Exception var3) {
                var3.printStackTrace();
                return false;
            }
        } else {
            return false;
        }
    }
 
    public static boolean equalOneMd5(String md5String, String sourceString) {
        if (md5String != null && sourceString != null) {
            try {
                String ms = md5(sourceString);
                return md5String.equals(ms);
            } catch (Exception var3) {
                if (logger.isErrorEnabled()) {
                    logger.error("对比md5的时候出现了错误", var3);
                }
 
                return false;
            }
        } else {
            return false;
        }
    }
 
    private static String toHex(byte[] buffer) {
        StringBuffer sb = new StringBuffer(32);
        String s = null;
 
        for(int i = 0; i < buffer.length; ++i) {
            s = Integer.toHexString(buffer[i] & 255);
            if (s.length() < 2) {
                sb.append('0');
            }
 
            sb.append(s);
        }
 
        return sb.toString();
    }
}