> ## Documentation Index
> Fetch the complete documentation index at: https://docs.js-confuser.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Variable Masking

> Local variables are consolidated into a rotating array.

* Option name: `"variableMasking"`

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

***

### Input / Output

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

```js title="Input.js" lines interactive-mode="obfuscate" theme={null}
// Input.js
function add3(x, y, z) {
  return x + y + z;
}

console.log(add3(1, 2, 3)); // 6

// Output.js
function rN9eAO(...rN9eAO) {
  return rN9eAO[0] + rN9eAO[1] + rN9eAO[2];
}
console.log(rN9eAO(1, 2, 3));
```

***

### Custom Implementation

#### `options.variableMasking(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`.

```js title="Usage Example" lines theme={null}
import JSConfuser from "js-confuser";
import {readFileSync, writeFileSync} from "fs";

// Read input code
const sourceCode = readFileSync("input.js", "utf8");
const options = {
  target: 'browser',
  variableMasking: true,
};

JSConfuser.obfuscate(sourceCode, options).then((result)=>{
  // Write output code
  writeFileSync("output.js", result.code);
}).catch(err=>{
  // Error occurred
  console.error(err);  
});
```

***

#### Enabled In

* [High Preset](/presets/high): Yes (75%)
* [Medium Preset](/presets/medium): Yes (50%)
* [Low Preset](/presets/low): No
