Protect Java Library
Protect Java Library with GUI Tool
Go to the Protector4J folder, execute p4j-ui[.exe], you will see the following user interface.
For macOS users, simply double-click on Protector4J.app like a regular Mac application.
Login
If you have already purchased the license, please click on the login button in the upper right corner and input your user information. If you do not have a license, you can still try out this tool.
The Java library protection feature requires the Enterprise edition.
Selection Application Type
Click on the "Java Library" button on the application type page
Select the jar/war file that needs to be encrypted
Select the jar/war files you want to encrypt, you can select one or multiple files
Specify the method to encrypt
On this page you can select the method to encrypt
You can select the classes and methods that need protection from the structure directory on the right, or you can manually enter the items that need protection in the following format.
# Protect a method
# Class name.method name&method signature
Hello.hello&()V
# Protect all methods under the class
# Directly input the class name
Hello
You can enter the content to be excluded in the Items to exclude using the same format.
Protect Java Library with CLI Tool
Configuration file
CLI tool need to specify a task file as a parameter.
Go to the protector4j/task-templates
folder, find java-lib-task.yml
, copy and modify one.
# The jar files that need to be encrypted
jarFiles: []
# Protect a method: MethodName&MethodSignature, like io.test.Hello.hello&()V
# Protect all methods in a Class: ClassName, like io.test.Hello
itemsToProtect: []
# Exclude items that are not encrypted in the same format as itemsToProtect.
itemsToExclude: []
# The output folder
outputFolder: ''
# Create a new and unique folder for the application, the folder name is like p4j-<taskId>
createNewFolder: true
Excute encryption task
Go to the Protector4J folder and execute the following command.
Linux or macOS
For macOS users, you can find the CLI tool at /Applictions/Protector4J.app/Contents/protector4j-mac
.
./p4j -t java-lib -f path-of-task-file -u email -p password
Windows
p4j -t java-lib -f path-of-task-file -u email -p password
You can execute p4j --help
to view the detailed parameters.
The result of Encryption
Unlike the overall encryption of Java applications, Java library encryption targets specific methods. After encryption is completed, the method you selected will be converted into native code, which can be used in conjunction with a standard JRE. If users need to crack it, they must do so at the binary level rather than the bytecode level, significantly increasing the difficulty of cracking.
Before encryption
After encryption
After encryption is complete, the Main method is converted to a native method.
Limitations
- Doesn't support try-catch code blocks.
- Doesn't Spring Boot packaged jar files.
- Doesn't war files
Demo Application
Currently Java Library Encryption function does not support free user trial, you can download this demo application to see the effect of Java library encryption, this is a swingapp program, you can use java -jar swingapp.jar
to run it, its main function is converted to a native method, you can use the decompiler tool for verification!
Unencrypted Application
Encrypted Application