dev.ts 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. 'use strict';
  2. import { NO_ADDITIONAL_NODES_PRESET } from '../../src/options/presets/NoCustomNodes';
  3. import { StringArrayIndexesType } from '../../src/enums/node-transformers/string-array-transformers/StringArrayIndexesType';
  4. (function () {
  5. const JavaScriptObfuscator: any = require('../../index');
  6. let obfuscatedCode: string = JavaScriptObfuscator.obfuscate(
  7. `
  8. const foo = 'foo';
  9. const bar = 'bar';
  10. function test1 () {
  11. const baz = 'baz';
  12. function test2() {
  13. const bark = 'bark';
  14. console.log(bark);
  15. }
  16. console.log(baz);
  17. test2();
  18. }
  19. console.log(foo, bar);
  20. test1();
  21. `,
  22. {
  23. ...NO_ADDITIONAL_NODES_PRESET,
  24. compact: false,
  25. rotateStringArray: true,
  26. shuffleStringArray: true,
  27. stringArray: true,
  28. stringArrayIndexesType: [
  29. StringArrayIndexesType.HexadecimalNumericString,
  30. StringArrayIndexesType.HexadecimalNumber
  31. ],
  32. stringArrayIndexShift: true,
  33. stringArrayThreshold: 1,
  34. stringArrayWrappersCount: 2,
  35. stringArrayWrappersChainedCalls: true,
  36. stringArrayWrappersType: 'function'
  37. }
  38. ).getObfuscatedCode();
  39. console.log(obfuscatedCode);
  40. console.log(eval(obfuscatedCode));
  41. })();