> ## 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.

# Global Concealing

> Global Concealing hides global variables being accessed.

* Option name: `"globalConcealing"`

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

***

### Input / Output

This example showcases how `Global Concealing` 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
console.log('Hello World');

// Output.js
var G5Qiu1 = pWw0jM1();
function pWw0jM1() {
  var G5Qiu1 = [
      function () {
        return globalThis;
      },
      function () {
        return global;
      },
      function () {
        return window;
      },
      function () {
        return new Function('return this')();
      },
    ],
    pWw0jM1,
    HQnyGG = [];
  try {
    pWw0jM1 = Object;
    HQnyGG.push(''.__proto__.constructor.name);
  } catch (e) {}
  Kf12fHC: for (var JOIGRCq = 0; JOIGRCq < G5Qiu1.length; JOIGRCq++)
    try {
      pWw0jM1 = G5Qiu1[JOIGRCq]();
      for (var TFKToP = 0; TFKToP < HQnyGG.length; TFKToP++)
        if (typeof pWw0jM1[HQnyGG[TFKToP]] === 'undefined') continue Kf12fHC;
      return pWw0jM1;
    } catch (e) {}
  return pWw0jM1 || this;
}
function HQnyGG(pWw0jM1) {
  switch (pWw0jM1) {
    case 'ewD3me':
      return G5Qiu1.BEPmA5F;
    case '8gATDe':
      return G5Qiu1.T1_swQN;
    case 'v8WyzWc':
      return G5Qiu1.F2Myzp7;
    case 'caWYDuD':
      return G5Qiu1.OJwPi1Q;
    case 'DDhsP6':
      return G5Qiu1.YpDcIuV;
    case 'g7UQLGk':
      return G5Qiu1.buZ4mhu;
    case 'byr9MVH':
      return G5Qiu1.qvi4t4;
    case 'u0lyvP':
      return G5Qiu1.uaLNHhJ;
    case 'g1A65k':
      return G5Qiu1.DT_HnxX;
    case 'Dy2uRTL':
      return G5Qiu1.iRsLvT;
    case 'brxH7K':
      return G5Qiu1.FdZeOG;
    case 'hnkhT8w':
      return G5Qiu1.ovOKR3v;
    case 'PZEy1li':
      return G5Qiu1.fCSm5Q;
    case 'oB2w2O':
      return G5Qiu1.hRIOOZ;
    case 'iWwnFh':
      return G5Qiu1.DxLQErb;
    case 'vN7vvp':
      return G5Qiu1.AWek9c4;
    case 'twX5v0x':
      return G5Qiu1.xVi_iS;
    case 'UwGgh2':
      return G5Qiu1.console;
    case 'zK0PZnP':
      return G5Qiu1.MCmXvg;
    case 'IFDz6j':
      return G5Qiu1.sSGB3y;
    case 'SakajjH':
      return G5Qiu1.eLWH32i;
    case 'mK2ZUrC':
      return G5Qiu1.eeY7ZH;
    case '50UoID':
      return G5Qiu1.esBILoV;
    case '9WBklJ':
      return G5Qiu1.WlB6jeg;
    case 'unVmnA':
      return G5Qiu1.Y43n79Y;
    case 'x6jjY9':
      return G5Qiu1.Ck7qca;
    case 'O832ee':
      return G5Qiu1.OP7h7o;
    case 'nuwLQ4':
      return G5Qiu1.xAic_Yo;
    case 'V1kStx':
      return G5Qiu1.nXdxec;
    case 'HxFWkqw':
      return G5Qiu1.IvHNkL;
    case '4nueaU':
      return G5Qiu1.czT5JU;
    case 'f655MaX':
      return G5Qiu1.eZtW_U;
    case 'qX8OEU':
      return G5Qiu1.hulcok;
    case '8tl1d0m':
      return G5Qiu1.Sx6l0Y;
    case 'UEeINh':
      return G5Qiu1.F8uaz2g;
    case 'pRCNyE':
      return G5Qiu1.Ujoo2k;
    case 'UMjEeWg':
      return G5Qiu1.VRUolre;
    case 'ACe8MxF':
      return G5Qiu1.E5w5wxI;
    case 'Sr5LJpf':
      return G5Qiu1.SaNNdBt;
  }
}
HQnyGG('UwGgh2').log('Hello World');
```

***

### Custom Implementation

#### `options.globalConcealing(name)`

Control which globals are changed. Returns a `boolean`.

| Parameter | Type     | Description                                   |
| --------- | -------- | --------------------------------------------- |
| `name`    | `string` | The global variable proposed to be concealed. |

***

### 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',
  globalConcealing: 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
* [Medium Preset](/presets/medium): Yes
* [Low Preset](/presets/low): No
