tags: java Anti -compilation spring boot
Official document address: https://github.com/core-lib/xjar
Packing integrated plug-in: https://github.com/core-lib/xjar- maven-plugin
XJAR needs the support of the GO environment. You can download the installation package through the link below:
Go Language Official Website: https://golang.google.cn
JDK himself uses 1.8
Add the following attributes to pom.xml, pay attention to the copy location
<project>
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>com.github.core-lib</groupId>
<artifactId>xjar</artifactId>
<version>4.0.2</version>
</dependency>
</dependencies>
</project>
public static void main(String[] args) throws Exception {
XCryptos.encryption()
.from("system/start/target/start-1.0.0-SNAPSHOT.jar")
.use("1qaz2wsx3edc")
.include("/**/*.class")
.include("/**/*.yml")
.include("/**/*.xml")
.to("D:\\sercetJar\\springboot.jar");
}
in
"System/Start/Target/Start-1.0.0-Snapshot.jar" is the JAR package path that needs to be encrypted (you can also use the absolute path)
"1QAZ2WSX3EDC" is the secret of encryption
"D: \ Sercentjar \ SpringBoot.jar" is the storage path of the encrypted jar package
More parameters can be viewed on the official website
Run 3.2 code, generate decryption files and encrypted jar packages, as shown below:

Open the command interface in the directory where the jar package is located, enter Go Build xjar.go to get xjar.exe files

Start the application, the command interface input xjar.exe java -java -jar generated JAR name items

The picture below is the result of using JD-GUI for counter-compilation

It can be found that it can no longer compile.
At this point, the JAR package has been encrypted, and you can also learn more about Github.
Maven projects can be integrated with XJAR-Maven-Plugin to avoid the above code every time you encrypted. As Maven constructs the automatic production of JAR and Go starter source files after automatic production encryption is built
<project>
<!-Set jitpack.io plug-in warehouse->
<pluginRepositories>
<pluginRepository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</pluginRepository>
</pluginRepositories>
<!-Add XJAR Maven plug-in->
<build>
<plugins>
<plugin>
<groupId>com.github.core-lib</groupId>
<artifactId>xjar-maven-plugin</artifactId>
<version>4.0.2</version>
<executions>
<execution>
<goals>
<goal>build</goal>
</goals>
<phase>package</phase>
<!- or use
<phase>install</phase>
-->
<configuration>
<!-Password is not recommended to configure in POM files->
<!--<password>io.xjar</password> -->
<!-- optional
<algorithm/>
<keySize/>
<ivSize/>
<includes>
<include/>
</includes>
<excludes>
<exclude/>
</excludes>
<sourceDir/>
<sourceJar/>
<targetDir/>
<targetJar/>
-->
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
For the Spring Boot project or module, the plug-in will be executed at Spring-Boot-Maven-Plugin plug-in. There are two ways:
Place the plug-in behind Spring-Boot-Maven-Plugin, because the default Phase of its plugin is also Package
Set the plug -in Phase to Install (the default value is: Package), and the packing command is used by the MVN CLEAN Install
You can also execute it through the Maven command
mvn xjar:build -Dxjar.password=io.xjar
mvn xjar:build -Dxjar.password=io.xjar -Dxjar.targetDir=/directory/to/save/target.xjar
However, it is usually allowed to be bound to the XJAR plug -in to automatically execute in the specified PHASE, so that the encrypted package can be automatically constructed when the project is constructed.
mvn clean package -Dxjar.password=io.xjar
mvn clean install -Dxjar.password=io.xjar -Dxjar.targetDir=/directory/to/save/target.xjar


After executing the packing command, you can automatically build an encrypted jar package.
Step on the pit:
Due to the use of the Alibaba Maven mirror image, it is impossible to download xjar dependencies from Jitpack.io
Refer to the following settings, add in the mirrorof element configuration of the image,! Jitpack.io end.
<mirror>
<id>alimaven</id>
<mirrorOf>central,!jitpack.io</mirrorOf>
<name>aliyun maven</name>
<url>http://maven.aliyun.com/nexus/content/repositories/central/</url>
</mirror>
Xjar introduction Spring boot JAR securely encrypts running tool while supporting native JAR. Based on the encryption of the JAR package and the construction of a program encryption, dynamically decry...
jar bag cryptocarnot support,springBoot+jpa(hibernate) Sometimes, people have to deploy customers, but what customers buy are your products, not your source code. At this time, in order to prevent, ot...
Enter the Maven command: MVN CLEAN PACKAGE "-dxjar.password = ****" "-DMaven.test.Skip = TRUE" generates the encrypted jar file, the file is generated in target/xjardir; Enter Go B...
ASM is an open source application framework for JAVA bytecode analysis, creation and modification. It can dynamically generate stub classes or other proxy classes in binary format, or dynamically modi...
Use JavaScript to call the jar package in Kettle to MD5 encrypt the content of the file 1. The main knowledge points of this article: JavaScript calls the jar package to encrypt the content of the fil...
The jar package code is very important. We need to protect our intellectual property rights, so encryption becomes a very important technology. Let's talk about an open source (open source everyone kn...
1. Integrated 1. Official introduction address Manual encryption:https://github.com/core-lib/xjar Maven plugin integration:https://github.com/core-lib/xjar-maven-plugin 2. Add warehouse and plug -in T...
1. Download the maven encryption plugin Add the following configuration to the pom file Then execute clean install start up The content of stm.key If hlod is false, the stm.key file will...
1. Introducing Maven Dependent (Instance) 2. I directly write a main method encrypted and successfully encrypt successfully to generate a jar package with xjar.go files in the directory specified by t...
First prepare the encryption code: The user is required to enter the data that needs to be encrypted. After completion, create a new file in the same level directory of the jar package (the code will ...