dev.ts 1.3 KB

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