一、加密
1、对需要加密的class文件字节码进行加密
2、不加密Application入口程序文件
3、不加密或改变文件名
二、解密
对class文件的字节流进行解密,在很多地方都有读取class的方法:
1、springboot,必需
org.springframework.boot.loader.LauchedURLClassLoader
2、spring-core,必需
org.springframework.core.type.classreading.SimpleMetadataReader
3、tomcat、aspect等其他,看需求
xjar加解密
1、支持maven加密打包
2、支持java代码实现jar包加密
3、支持SpringBoot项目
4、可配置密码,且密码隐蔽不易泄露
码云:https://gitee.com/core-lib/xjar/tree/4.0.1
<!-- 设置 jitpack.io 插件仓库 -->
<pluginRepositories>
<pluginRepository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</pluginRepository>
</pluginRepositories>
<build>
<plugins>
<plugin>
<groupId>com.github.core-lib</groupId>
<artifactId>xjar-maven-plugin</artifactId>
<version>4.0.1</version>
<executions>
<execution>
<goals>
<goal>build</goal>
</goals>
<phase>package</phase>
<configuration>
<password>lufei</password>
<includes>
<include>/com/**/**/*</include>
</includes>
<sourceDir>${project.build.directory}</sourceDir>
<sourceJar>${project.build.finalName}.jar</sourceJar>
<targetDir>${project.build.directory}</targetDir>
<targetJar>${project.build.finalName}-encrypted.jar</targetJar>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>