mirror of
https://github.com/javascript-obfuscator/javascript-obfuscator
synced 2026-08-09 12:42:29 +00:00
added Utils static property with pool for random generator
This commit is contained in:
Vendored
+10
-7
@@ -225,10 +225,12 @@ var Utils = function () {
|
||||
}
|
||||
return result;
|
||||
};
|
||||
var customPool = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
|
||||
var randomString = Utils.randomGenerator.string({ length: length, pool: customPool }),
|
||||
randomStringDiff = randomString.replace(new RegExp('[' + escapeRegExp(str) + ']', 'g'), ''),
|
||||
randomStringDiffArray = randomStringDiff.split('');
|
||||
var randomString = Utils.randomGenerator.string({
|
||||
length: length,
|
||||
pool: Utils.randomGeneratorPool
|
||||
});
|
||||
var randomStringDiff = randomString.replace(new RegExp('[' + escapeRegExp(str) + ']', 'g'), '');
|
||||
var randomStringDiffArray = randomStringDiff.split('');
|
||||
Utils.randomGenerator.shuffle(randomStringDiffArray);
|
||||
randomStringDiff = randomStringDiffArray.join('');
|
||||
return [randomMerge(str, randomStringDiff), randomStringDiff];
|
||||
@@ -340,6 +342,7 @@ var Utils = function () {
|
||||
return Utils;
|
||||
}();
|
||||
|
||||
Utils.randomGeneratorPool = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
||||
Utils.randomGenerator = new chance_1.Chance();
|
||||
exports.Utils = Utils;
|
||||
|
||||
@@ -1222,7 +1225,7 @@ var StringLiteralReplacer = function (_AbstractReplacer_1$A) {
|
||||
value: function replaceStringLiteralWithStringArrayCall(value) {
|
||||
var stringArrayNode = this.nodes.get('stringArrayNode');
|
||||
if (!stringArrayNode) {
|
||||
throw new ReferenceError('`stringArrayNode` node is not found in Map with custom node.');
|
||||
throw new ReferenceError('`stringArrayNode` node is not found in Map with custom nodes.');
|
||||
}
|
||||
var rc4Key = '';
|
||||
switch (this.options.stringArrayEncoding) {
|
||||
@@ -3120,11 +3123,11 @@ var AbstractControlFlowReplacer = function () {
|
||||
}
|
||||
|
||||
_createClass(AbstractControlFlowReplacer, null, [{
|
||||
key: 'getStorageKey',
|
||||
key: "getStorageKey",
|
||||
value: function getStorageKey() {
|
||||
return Utils_1.Utils.getRandomGenerator().string({
|
||||
length: 3,
|
||||
pool: 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
|
||||
pool: Utils_1.Utils.randomGeneratorPool
|
||||
});
|
||||
}
|
||||
}]);
|
||||
|
||||
+14
-6
@@ -5,6 +5,11 @@ import { JSFuck } from './enums/JSFuck';
|
||||
const isEqual = require('is-equal');
|
||||
|
||||
export class Utils {
|
||||
/**
|
||||
* @type {string}
|
||||
*/
|
||||
public static randomGeneratorPool: string = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
||||
|
||||
/**
|
||||
* @type {Chance.Chance | Chance.SeededChance}
|
||||
*/
|
||||
@@ -180,13 +185,16 @@ export class Utils {
|
||||
return result;
|
||||
};
|
||||
|
||||
const customPool: string = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
|
||||
const randomString: string = Utils.randomGenerator.string({
|
||||
length: length,
|
||||
pool: Utils.randomGeneratorPool
|
||||
});
|
||||
|
||||
let randomString: string = Utils.randomGenerator.string({length: length, pool: customPool}),
|
||||
randomStringDiff: string = randomString.replace(
|
||||
new RegExp('[' + escapeRegExp(str) + ']', 'g'),
|
||||
''),
|
||||
randomStringDiffArray: string[] = randomStringDiff.split('');
|
||||
let randomStringDiff: string = randomString.replace(
|
||||
new RegExp('[' + escapeRegExp(str) + ']', 'g'),
|
||||
'');
|
||||
|
||||
const randomStringDiffArray: string[] = randomStringDiff.split('');
|
||||
|
||||
Utils.randomGenerator.shuffle(randomStringDiffArray);
|
||||
randomStringDiff = randomStringDiffArray.join('');
|
||||
|
||||
Vendored
+1
-1
@@ -2,7 +2,7 @@ export interface IStorage <T> {
|
||||
get (key: string | number): T;
|
||||
getKeyOf (value: T): string | number | null;
|
||||
getLength (): number;
|
||||
getStorage (): Map <string | number, T> | T[];
|
||||
getStorage (): any;
|
||||
set (key: string | number | null, value: T): void;
|
||||
toString (): string;
|
||||
}
|
||||
|
||||
+1
-1
@@ -33,7 +33,7 @@ export abstract class AbstractControlFlowReplacer implements IControlFlowReplace
|
||||
protected static getStorageKey (): string {
|
||||
return Utils.getRandomGenerator().string({
|
||||
length: 3,
|
||||
pool: 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
|
||||
pool: Utils.randomGeneratorPool
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ export class StringLiteralReplacer extends AbstractReplacer {
|
||||
const stringArrayNode: ICustomNodeWithData = <ICustomNodeWithData>this.nodes.get('stringArrayNode');
|
||||
|
||||
if (!stringArrayNode) {
|
||||
throw new ReferenceError('`stringArrayNode` node is not found in Map with custom node.');
|
||||
throw new ReferenceError('`stringArrayNode` node is not found in Map with custom nodes.');
|
||||
}
|
||||
|
||||
let rc4Key: string = '';
|
||||
|
||||
Reference in New Issue
Block a user