xml version="1.0" encoding="UTF-8"
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>my-app</artifactId>
<version>1.0.0-SNAPSHOT</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.release>11</maven.compiler.release>
<jobfuscator.apiKey><!-- YOU-API-HERE or leave empty for DEMO VERSION --></jobfuscator.apiKey>
<jobfuscator.version><!-- e.g. 1.0.3 --></jobfuscator.version>
</properties>
<dependencies>
<dependency>
<groupId>com.pelock</groupId>
<artifactId>jobfuscator-annotations</artifactId>
<version>${jobfuscator.version}</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>com.pelock</groupId>
<artifactId>jobfuscator-maven-plugin</artifactId>
<version>${jobfuscator.version}</version>
<executions>
<execution>
<goals>
<goal>obfuscate-sources</goal>
</goals>
<phase>generate-sources</phase>
</execution>
</executions>
<configuration>
<apiKey>${jobfuscator.apiKey}</apiKey>
<enableCompression>true</enableCompression>
<mixCodeFlow>true</mixCodeFlow>
<renameVariables>true</renameVariables>
<renameMethods>true</renameMethods>
<shuffleMethods>true</shuffleMethods>
<intsMathCrypt>true</intsMathCrypt>
<cryptStrings>true</cryptStrings>
<stringSplit>true</stringSplit>
<intsToArrays>true</intsToArrays>
<dblsToArrays>true</dblsToArrays>
<dblsMathCrypt>true</dblsMathCrypt>
<stringCharVault>true</stringCharVault>
<intsFromDoubleMath>true</intsFromDoubleMath>
<opaqueMixerChain>true</opaqueMixerChain>
<complexifyBooleans>true</complexifyBooleans>
<tryFinallyNoise>true</tryFinallyNoise>
<selfCheck>true</selfCheck>
<arrayIntCrypt>true</arrayIntCrypt>
<arrayCharCrypt>true</arrayCharCrypt>
<arrayDoubleCrypt>true</arrayDoubleCrypt>
<arrayStringCrypt>true</arrayStringCrypt>
<selfCheck>true</selfCheck>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.13.0</version>
<configuration>
<release>${maven.compiler.release}</release>
</configuration>
</plugin>
</plugins>
</build>
</project>
Step 2 - prepare your source codes
Annotate your sources to enable obfuscation in the build process:
import java.util.*;
import java.lang.*;
import java.io.*;
//
// you MUST include a custom annotation
// to enable the entire class or a single
// method obfuscation
//
@Obfuscate
class Ideone
{
//@Obfuscate
public static double calculateSD(double numArray[])
{
double sum = 0.0, standardDeviation = 0.0;
int length = numArray.length;
for(double num : numArray) {
sum += num;
}
double mean = sum/length;
for(double num: numArray) {
standardDeviation += Math.pow(num - mean, 2);
}
return Math.sqrt(standardDeviation/length);
}
//
// selective obfuscation strategies
// can be applied for the entire
// class or a single method (by
// default all obfuscation strategies
// are enabled when you use @Obfuscate
// annotation alone)
//
//@Obfuscate(
// ints_math_crypt = true,
// dbls_math_crypt = true,
// string_split = true,
// crypt_strings = true,
// string_char_vault = true,
// rename_methods = false,
// rename_variables = true,
// shuffle_methods = true,
// array_int_crypt = true,
// array_double_crypt = true,
// array_char_crypt = true,
// array_string_crypt = true,
// mix_code_flow = true,
// ints_from_double_math = true,
// opaque_mixer_chain = true,
// complexify_booleans = true,
// try_finally_noise = true,
// ints_to_arrays = true,
// dbls_to_arrays = true,
// self_check = true
// )
public static void main(String[] args) {
double[] numArray = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
double SD = calculateSD(numArray);
System.out.format("Standard Deviation = %.6f", SD);
}
}
And that's all! Just build your project like you did before. The obfuscation process is automated and fully invisible to you.
For more obfuscation features of the Maven plugin please refer to the official JObfuscator Maven Compiler documentation.
No comments:
Post a Comment