mirror of
https://github.com/javascript-obfuscator/javascript-obfuscator
synced 2026-08-09 12:42:29 +00:00
increased runtime speed with encoding: fixed test
This commit is contained in:
Vendored
+1
-3
@@ -2435,9 +2435,7 @@ var Obfuscator = Obfuscator_1 = function () {
|
||||
if (this.options.controlFlowFlattening) {
|
||||
astTree = this.transformAstTree(astTree, VisitorDirection_1.VisitorDirection.leave, this.nodeTransformersFactory(Obfuscator_1.nodeControlFlowTransformersMap));
|
||||
}
|
||||
console.time();
|
||||
astTree = this.transformAstTree(astTree, VisitorDirection_1.VisitorDirection.enter, this.nodeTransformersFactory(Obfuscator_1.nodeObfuscatorsMap));
|
||||
console.timeEnd();
|
||||
this.obfuscationEventEmitter.emit(ObfuscationEvents_1.ObfuscationEvents.AfterObfuscation, astTree, stackTraceData);
|
||||
return astTree;
|
||||
}
|
||||
@@ -7609,7 +7607,7 @@ exports.SelfDefendingTemplate = SelfDefendingTemplate;
|
||||
|
||||
|
||||
function StringArrayBase64DecodeNodeTemplate() {
|
||||
return " \n if ({stringArrayCallsWrapperName}.initialized === undefined) {\n {atobPolyfill}\n \n {stringArrayCallsWrapperName}.base64DecodeUnicode = function (str) {\n var string = atob(str);\n var newStringChars = [];\n \n for (var i = 0, length = string.length; i < length; i++) {\n newStringChars += '%' + ('00' + string.charCodeAt(i).toString(16)).slice(-2);\n }\n \n return decodeURIComponent(newStringChars);\n };\n \n {stringArrayCallsWrapperName}.data = {};\n \n {stringArrayCallsWrapperName}.initialized = true;\n }\n \n if (!{stringArrayCallsWrapperName}.data[index]) {\n {selfDefendingCode}\n \n value = {stringArrayCallsWrapperName}.base64DecodeUnicode(value);\n {stringArrayCallsWrapperName}.data[index] = value;\n } else {\n value = {stringArrayCallsWrapperName}.data[index];\n } \n ";
|
||||
return " \n if ({stringArrayCallsWrapperName}.initialized === undefined) {\n {atobPolyfill}\n \n {stringArrayCallsWrapperName}.base64DecodeUnicode = function (str) {\n var string = atob(str);\n var newStringChars = [];\n \n for (var i = 0, length = string.length; i < length; i++) {\n newStringChars += '%' + ('00' + string.charCodeAt(i).toString(16)).slice(-2);\n }\n \n return decodeURIComponent(newStringChars);\n };\n \n {stringArrayCallsWrapperName}.data = {};\n \n {stringArrayCallsWrapperName}.initialized = true;\n }\n \n if ({stringArrayCallsWrapperName}.data[index] === undefined) {\n {selfDefendingCode}\n \n value = {stringArrayCallsWrapperName}.base64DecodeUnicode(value);\n {stringArrayCallsWrapperName}.data[index] = value;\n } else {\n value = {stringArrayCallsWrapperName}.data[index];\n } \n ";
|
||||
}
|
||||
exports.StringArrayBase64DecodeNodeTemplate = StringArrayBase64DecodeNodeTemplate;
|
||||
|
||||
|
||||
@@ -137,13 +137,11 @@ export class Obfuscator implements IObfuscator {
|
||||
}
|
||||
|
||||
// second pass: nodes obfuscation
|
||||
console.time();
|
||||
astTree = this.transformAstTree(
|
||||
astTree,
|
||||
VisitorDirection.enter,
|
||||
this.nodeTransformersFactory(Obfuscator.nodeObfuscatorsMap)
|
||||
);
|
||||
console.timeEnd();
|
||||
|
||||
this.obfuscationEventEmitter.emit(ObfuscationEvents.AfterObfuscation, astTree, stackTraceData);
|
||||
|
||||
|
||||
+1
-1
@@ -22,7 +22,7 @@ export function StringArrayBase64DecodeNodeTemplate (): string {
|
||||
{stringArrayCallsWrapperName}.initialized = true;
|
||||
}
|
||||
|
||||
if (!{stringArrayCallsWrapperName}.data[index]) {
|
||||
if ({stringArrayCallsWrapperName}.data[index] === undefined) {
|
||||
{selfDefendingCode}
|
||||
|
||||
value = {stringArrayCallsWrapperName}.base64DecodeUnicode(value);
|
||||
|
||||
+1
-1
@@ -20,7 +20,7 @@ describe('StringArrayCallsWrapper', () => {
|
||||
|
||||
assert.match(
|
||||
obfuscationResult.getObfuscatedCode(),
|
||||
/var *_0x([a-z0-9]){4,6} *= *parseInt\(_0x([a-z0-9]){4,6}, *0x10\);/
|
||||
/_0x([a-z0-9]){4,6} *= *_0x([a-z0-9]){4,6} *- *0x0\;/
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user