Getting started

Quick start

Protect a first jar with a minimal configuration and a profile.

This page takes a compiled jar from your build and produces a protected copy with a profile and nothing else. It assumes the CLI is installed and your licence is active on this machine.

Write a configuration

Create obfuscator-config.json next to your build:

{
  "input": "build/libs/app.jar",
  "output": "build/libs/app-protected.jar",
  "libraries": ["libs/dependency.jar"],
  "options": {
    "profile": "Medium"
  }
}
  • input is the jar to protect and output the jar HashGuard writes.
  • libraries lists the jars your code depends on. HashGuard reads them to resolve the class hierarchy and compute stack frames; it never modifies them. Leave the array empty if the jar has no dependencies.
  • profile sets a baseline of protections. Medium adds string encryption, constant masking and call indirection on top of renaming. See Profiles.

The file must be strict JSON: no comments, no trailing commas.

Run it

hashguard -config obfuscator-config.json

The CLI checks the licence, runs the pipeline phase by phase and writes build/libs/app-protected.jar. Run your test suite or start the application from the protected jar to check that it behaves like the original.

When something breaks

Most issues come from code that relies on names: reflection, serialization, configuration files that name classes, service loaders. Keep those names:

Next steps

  • Raise the profile, or switch individual passes on and off, with the options.
  • Export a mapping to decode stack traces from production.
  • Run HashGuard from your build with the Gradle plugin, or in CI.