Integrity

Integrity ensures the source code is unchanged.

Option name: "lock.integrity"

Option values: true/false/0-1/Function


Input / Output

This example showcases how Integrity transforms the code. Try it out by changing the input code and see changes apply in real-time.

Input.js

Loading...

Output.js

Loading...

How is this possible?

JavaScript has a sneaky method to view the source code any function. Calling Function.toString() on any function reveals the raw source code.

Integrity uses a hashing algorithm on the obfuscated code during the obfuscation-phase. The obfuscator then places checksum functions throughout the output code to verify it's unchanged at runtime.

An additional RegEx is utilized to remove spaces, newlines, braces, and commas. This ensures the hash isn't too sensitive.

Tamper Detection

If tampering is detected, the lock.countermeasures function will be invoked. If you don't provide a lock.countermeasures function, the default behavior is to crash the program.

Learn more about the countermeasures function


Custom Implementation

options.lock.integrity(fnName)

Control which functions are changed. Returns a boolean.

Parameter Type Description
fnName string The function name proposed to be changed.

Usage Example

The provided code example will obfuscate the file input.js and write the output to a file named output.js.

Usage Example

Loading...

Enabled In

Potential Issues

If you decide to use Integrity, consider the following:

  1. Any build-tools must not modify the locked code. The code can't be changed after JS-Confuser is applied.
  2. Function.toString() functionality may not be enabled in your environment (bytenode)

See Also