Fixed very rare cases when rotateStringArray couldn't rotate array properly

This commit is contained in:
sanex
2021-08-02 12:25:45 +03:00
parent 73fcb350a2
commit 6e1ce07b5e
9 changed files with 112 additions and 50 deletions
+13 -35
View File
@@ -1,47 +1,25 @@
'use strict';
import { NO_ADDITIONAL_NODES_PRESET } from '../../src/options/presets/NoCustomNodes';
import { readFileAsString } from '../helpers/readFileAsString';
(function () {
const JavaScriptObfuscator: any = require('../../index');
const code: string = readFileAsString(__dirname + '/../functional-tests/javascript-obfuscator/fixtures/custom-nodes-identifier-names-collision.js');
let obfuscatedCode: string = JavaScriptObfuscator.obfuscate(
`
class Test {
constructor () {
let test = {}
}
static methodA = () => {
console.log('method_A');
}
methodB () {
console.log('method_B');
Test.methodA();
}
}
const instance = new Test();
Test.methodA();
instance.methodB();
`,
let obfuscationResult = JavaScriptObfuscator.obfuscate(
code,
{
...NO_ADDITIONAL_NODES_PRESET,
compact: false,
simplify: false,
stringArray: true,
stringArrayThreshold: 1,
stringArrayEncoding: ['rc4', 'base64'],
stringArrayWrappersCount: 5,
rotateStringArray: true,
identifierNamesGenerator: 'mangled',
selfDefending: true
compact: false,
stringArray: true,
seed: 429105580
}
).getObfuscatedCode();
);
let obfuscatedCode: string = obfuscationResult.getObfuscatedCode();
let identifierNamesCache = obfuscationResult.getIdentifierNamesCache();
console.log(obfuscatedCode);
console.log(eval(obfuscatedCode));
})();
console.log(identifierNamesCache);
})();