对jar或者war进行加密解密
whycxzp
2021-12-22 f6b935781bcb43faea7aa894ce3a55873769efb3
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
package com.whyc;
 
/**
 * 常量
 *
 * @author perry
 */
public class Const {
    public static final String VERSION = "v1.2.1";
 
    //加密出来的文件名
    public static final String FILE_NAME = ".classes";
    //密码文件
    public static final String FILE_NAME2 = "launch_imp.dll";
    //密码
    public static final String FILE_NAME2_DESCRIPTION = "active code";
 
    //AES 16为key
    public static final String AES_KEY="wuhanyuanchangco";
 
    //lib下的jar解压的目录名后缀
    public static final String LIB_JAR_DIR = "__temp__";
 
    //默认加密方式
    public static final int ENCRYPT_TYPE = 1;
 
    //密码标记
    public static final String CONFIG_PASS = "org.springframework.config.Pass";
    //机器码标记
    public static final String CONFIG_CODE = "org.springframework.config.Code";
    //加密密码的hash
    public static final String CONFIG_PASSHASH = "org.springframework.config.PassHash";
 
    //本项目需要打包的代码
    public static final String[] CLASSFINAL_FILES = {"CoreAgent.class", "InputForm.class", "InputForm$1.class",
            "JarDecryptor.class", "AgentTransformer.class", "Const.class", "CmdLineOption.class",
            "EncryptUtils.class", "IoUtils.class", "JarUtils.class", "Log.class", "StrUtils.class",
            "SysUtils.class"};
 
    //调试模式
    public static boolean DEBUG = false;
 
    public static void pringInfo() {
        String sysName = System.getProperty("os.name");
        if (sysName.contains("Windows")) {
            System.out.println();
            System.out.println("=========================================================");
            System.out.println("=                                                       =");
            System.out.println("=      MyJava Class Encryption Tool " + VERSION + "     =");
            System.out.println("=                                                       =");
            System.out.println("=========================================================");
            System.out.println();
            return;
        }
 
 
        String[] color = {"\033[31m", "\033[32m", "\033[33m", "\033[34m", "\033[35m", "\033[36m",
                "\033[90m", "\033[92m", "\033[93m", "\033[94m", "\033[95m", "\033[96m"};
        System.out.println();
 
        for (int i = 0; i < 57; i++) {
            System.out.print(color[i % color.length] + "=\033[0m");
        }
        System.out.println();
        System.out.println("\033[34m=                                                       \033[92m=");
        System.out.println("\033[35m=       \033[31mJava \033[92mClass \033[95mEncryption \033[96mTool\033[0m \033[37m"
                + VERSION + "\033[0m   by \033[91mMr.K\033[0m     \033[93m=");
        System.out.println("\033[36m=                                                       \033[94m=");
        for (int i = 56; i >= 0; i--) {
            System.out.print(color[i % color.length] + "=\033[0m");
        }
        System.out.println();
        System.out.println();
    }
 
}