dev.ts 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. 'use strict';
  2. import { IdentifierNamesGenerator } from '../../src/enums/generators/identifier-names-generators/IdentifierNamesGenerator';
  3. (function () {
  4. const JavaScriptObfuscator: any = require('../../index');
  5. let obfuscatedCode: string = JavaScriptObfuscator.obfuscate(
  6. `
  7. // Paste your JavaScript code here
  8. function hi() {
  9. console.log("Hello World!");
  10. }
  11. hi();
  12. `,
  13. {
  14. compact: false,
  15. selfDefending: false,
  16. disableConsoleOutput: false,
  17. debugProtection: false,
  18. debugProtectionInterval: false,
  19. splitStrings: true,
  20. splitStringsChunkLength: 5,
  21. splitStringsChunkLengthEnabled: true,
  22. stringArray: true,
  23. rotateStringArray: false,
  24. rotateStringArrayEnabled: true,
  25. stringArrayThreshold: 1,
  26. stringArrayThresholdEnabled: true,
  27. stringArrayEncoding: false,
  28. stringArrayEncodingEnabled: true,
  29. sourceMap: false,
  30. sourceMapBaseUrl: "",
  31. sourceMapFileName: "",
  32. sourceMapSeparate: false,
  33. domainLock: [],
  34. reservedNames: [],
  35. reservedStrings: [],
  36. seed: 0,
  37. controlFlowFlatteningThreshold: 1,
  38. controlFlowFlattening: true,
  39. deadCodeInjectionThreshold: 1,
  40. deadCodeInjection: true,
  41. unicodeEscapeSequence: false,
  42. renameGlobals: true,
  43. identifierNamesGenerator: IdentifierNamesGenerator.DictionaryIdentifierNamesGenerator,
  44. identifiersDictionary: ["foo", "bar", "baz", "bark", "hawk", "fooz", "moscow", "chikago"],
  45. identifiersPrefix: "",
  46. transformObjectKeys: true
  47. }
  48. ).getObfuscatedCode();
  49. console.log(obfuscatedCode);
  50. console.log(eval(obfuscatedCode));
  51. })();