13693261870
2025-06-24 8565bd83fcd670ec8379084d600eb97d18037d21
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
package com.terra.system.helper;
 
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
 
import javax.crypto.Cipher;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;
import java.nio.charset.Charset;
 
/**
 * 许可帮助类
 * @author WWW
 */
public class LicHelper {
    private String a;
    private String b;
    private static String c;
    private static String d;
    private static String e;
    private static final Logger f;
 
    static {
        c = "utf-8";
        d = "AES";
        e = "AES/CBC/PKCS5Padding";
        f = LoggerFactory.getLogger(LicHelper.class);
    }
 
    private IvParameterSpec a() {
        try {
            return new IvParameterSpec(this.b.getBytes(c));
        } catch (Exception ex) {
            return null;
        }
    }
 
    public final String a(final String s) {
        String str = null;
        try {
            // final Cipher instance
            // (instance = Cipher.getInstance(e)).init(1, new SecretKeySpec(this.a.getBytes(c), d), this.a())
            // str = a(instance.doFinal(s.getBytes(Charset.forName(c))))
 
            Cipher instance = Cipher.getInstance(e);
            IvParameterSpec ips = this.a();
            SecretKeySpec sks = new SecretKeySpec(this.a.getBytes(c), d);
            instance.init(1, sks, ips);
 
            byte[] bytes = s.getBytes(Charset.forName(c));
            str = a(instance.doFinal(bytes));
        } catch (Exception ex) {
            System.out.println(ex.getStackTrace());
        }
        return str;
    }
 
    public final String b(final String s) {
        String s2 = null;
        try {
            final Cipher instance;
            (instance = Cipher.getInstance(e)).init(2, new SecretKeySpec(this.a.getBytes(c), d), this.a());
            s2 = new String(instance.doFinal(this.e(s)), c);
        } catch (Exception ex) {
            String str = ex.getMessage();
        }
        return s2;
    }
 
    private static String a(final byte[] array) {
        final StringBuilder sb = new StringBuilder();
        for (int i = 0; i < array.length; ++i) {
            final String hexString;
            if ((hexString = Integer.toHexString(array[i] & 0xFF)).length() < 2) {
                sb.append("0");
            }
            sb.append(hexString);
        }
        return sb.toString();
    }
 
    private byte[] e(String upperCase) {
        final int n = (upperCase = upperCase.toUpperCase()).length() / 2;
        final char[] charArray = upperCase.toCharArray();
        final byte[] array = new byte[n];
        for (int i = 0; i < n; ++i) {
            final int n2 = i << 1;
            array[i] = (byte) ((byte) "0123456789ABCDEF".indexOf(charArray[n2]) << 4 | (byte) "0123456789ABCDEF".indexOf(charArray[n2 + 1]));
        }
        return array;
    }
 
    public final void c(String string) {
        final String substring = (string = string).substring(2, 5);
        final StringBuilder sb;
        (sb = new StringBuilder(string)).replace(2, 5, string.substring(7, 10));
        sb.replace(7, 10, substring);
        string = sb.toString();
        this.a = string;
    }
 
    public final void d(final String b) {
        this.b = b;
    }
}