Integrity ensures the source code is unchanged.
Option name: "lock.integrity"
Option values: true/false/0-1/Function
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
Output.js
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.
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
Control which functions are changed. Returns a boolean.
Parameter | Type | Description |
---|---|---|
fnName | string | The function name proposed to be changed. |
The provided code example will obfuscate the file input.js and write the output to a file named output.js.
Usage Example
If you decide to use Integrity, consider the following: