forked from javascript-obfuscator/javascript-obfuscator
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStringArrayBase64DecodeTemplate.ts
More file actions
38 lines (31 loc) · 1.27 KB
/
Copy pathStringArrayBase64DecodeTemplate.ts
File metadata and controls
38 lines (31 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import { IRandomGenerator } from '../../../../interfaces/utils/IRandomGenerator';
/**
* @param {IRandomGenerator} randomGenerator
* @returns {string}
* @constructor
*/
export function StringArrayBase64DecodeTemplate (
randomGenerator: IRandomGenerator
): string {
const identifierLength: number = 6;
const initializedIdentifier: string = randomGenerator.getRandomString(identifierLength);
const base64Identifier: string = randomGenerator.getRandomString(identifierLength);
return `
if ({stringArrayCallsWrapperName}.${initializedIdentifier} === undefined) {
{atobPolyfill}
{stringArrayCallsWrapperName}.${base64Identifier} = {atobFunctionName};
{stringArrayCacheName} = arguments;
{stringArrayCallsWrapperName}.${initializedIdentifier} = true;
}
const firstValue = stringArray[0];
const cacheKey = index + firstValue;
const cachedValue = {stringArrayCacheName}[cacheKey];
if (!cachedValue) {
{selfDefendingCode}
value = {stringArrayCallsWrapperName}.${base64Identifier}(value);
{stringArrayCacheName}[cacheKey] = value;
} else {
value = cachedValue;
}
`;
}