mirror of
https://github.com/javascript-obfuscator/javascript-obfuscator
synced 2026-08-09 12:42:29 +00:00
New option: stringArrayIndexShift enables additional index shift for all string array calls
This commit is contained in:
@@ -20,6 +20,12 @@ import { NodeUtils } from '../../node/NodeUtils';
|
||||
|
||||
@injectable()
|
||||
export class StringArrayCallsWrapperCodeHelper extends AbstractCustomCodeHelper {
|
||||
/**
|
||||
* @type {number}
|
||||
*/
|
||||
@initializable()
|
||||
protected indexShiftAmount!: number;
|
||||
|
||||
/**
|
||||
* @type {string}
|
||||
*/
|
||||
@@ -68,13 +74,16 @@ export class StringArrayCallsWrapperCodeHelper extends AbstractCustomCodeHelper
|
||||
/**
|
||||
* @param {string} stringArrayName
|
||||
* @param {string} stringArrayCallsWrapperName
|
||||
* @param {number} indexShiftAmount
|
||||
*/
|
||||
public initialize (
|
||||
stringArrayName: string,
|
||||
stringArrayCallsWrapperName: string
|
||||
stringArrayCallsWrapperName: string,
|
||||
indexShiftAmount: number
|
||||
): void {
|
||||
this.stringArrayName = stringArrayName;
|
||||
this.stringArrayCallsWrapperName = stringArrayCallsWrapperName;
|
||||
this.indexShiftAmount = indexShiftAmount;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -97,7 +106,8 @@ export class StringArrayCallsWrapperCodeHelper extends AbstractCustomCodeHelper
|
||||
this.customCodeHelperFormatter.formatTemplate(StringArrayCallsWrapperTemplate(), {
|
||||
decodeCodeHelperTemplate,
|
||||
stringArrayCallsWrapperName: this.stringArrayCallsWrapperName,
|
||||
stringArrayName: this.stringArrayName
|
||||
stringArrayName: this.stringArrayName,
|
||||
indexShiftAmount: this.indexShiftAmount
|
||||
}),
|
||||
{
|
||||
reservedNames: preservedNames
|
||||
|
||||
@@ -142,7 +142,8 @@ export class StringArrayCodeHelperGroup extends AbstractCustomCodeHelperGroup {
|
||||
|
||||
stringArrayCallsWrapperCodeHelper.initialize(
|
||||
stringArrayName,
|
||||
stringArrayCallsWrapperName
|
||||
stringArrayCallsWrapperName,
|
||||
this.stringArrayStorage.getIndexShiftAmount()
|
||||
);
|
||||
|
||||
this.customCodeHelpers.set(stringArrayCallsWrapperCodeHelperName, stringArrayCallsWrapperCodeHelper);
|
||||
@@ -151,9 +152,11 @@ export class StringArrayCodeHelperGroup extends AbstractCustomCodeHelperGroup {
|
||||
// stringArrayRotateFunction helper initialize
|
||||
const stringArrayRotateFunctionCodeHelper: ICustomCodeHelper<TInitialData<StringArrayRotateFunctionCodeHelper>> =
|
||||
this.customCodeHelperFactory(CustomCodeHelper.StringArrayRotateFunction);
|
||||
const stringArrayRotationAmount: number = this.stringArrayStorage.getRotationAmount();
|
||||
|
||||
stringArrayRotateFunctionCodeHelper.initialize(stringArrayName, stringArrayRotationAmount);
|
||||
stringArrayRotateFunctionCodeHelper.initialize(
|
||||
stringArrayName,
|
||||
this.stringArrayStorage.getRotationAmount()
|
||||
);
|
||||
|
||||
if (this.options.rotateStringArray) {
|
||||
this.customCodeHelpers.set(CustomCodeHelper.StringArrayRotateFunction, stringArrayRotateFunctionCodeHelper);
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@
|
||||
export function StringArrayCallsWrapperTemplate (): string {
|
||||
return `
|
||||
const {stringArrayCallsWrapperName} = function (index, key) {
|
||||
index = index - 0;
|
||||
index = index - {indexShiftAmount};
|
||||
|
||||
let value = {stringArrayName}[index];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user