mirror of
https://github.com/javascript-obfuscator/javascript-obfuscator
synced 2026-08-09 12:42:29 +00:00
Increase random variable name length after name collision
This commit is contained in:
Vendored
+1
-8047
File diff suppressed because one or more lines are too long
@@ -41,6 +41,11 @@ export class RandomGenerator implements IRandomGenerator, IInitializable {
|
||||
*/
|
||||
private readonly options: IOptions;
|
||||
|
||||
/**
|
||||
* @type {number}
|
||||
*/
|
||||
private randomVariableNameAdditionalLength: number = 0;
|
||||
|
||||
/**
|
||||
* @type {Set<string>}
|
||||
*/
|
||||
@@ -89,8 +94,6 @@ export class RandomGenerator implements IRandomGenerator, IInitializable {
|
||||
|
||||
this.seed = this.options.seed !== 0 ? this.options.seed : getRandomInteger(0, 999999999);
|
||||
this.randomGenerator = new Chance(getSeed());
|
||||
|
||||
console.log(`seed is ${this.seed}`);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -151,10 +154,13 @@ export class RandomGenerator implements IRandomGenerator, IInitializable {
|
||||
const rangeMaxInteger: number = 99999999;
|
||||
const randomInteger: number = this.getRandomInteger(rangeMinInteger, rangeMaxInteger);
|
||||
const hexadecimalNumber: string = Utils.decToHex(randomInteger);
|
||||
const randomVariableName: string = `${prefix}${hexadecimalNumber.substr(0, length)}`;
|
||||
const randomVariableNameLength: number = length + this.randomVariableNameAdditionalLength;
|
||||
const randomVariableName: string = `${prefix}${hexadecimalNumber.repeat(2).substr(0, randomVariableNameLength)}`;
|
||||
|
||||
if (this.randomVariableNameSet.has(randomVariableName)) {
|
||||
return this.getRandomVariableName(length);
|
||||
this.randomVariableNameAdditionalLength++;
|
||||
|
||||
return this.getRandomVariableName(randomVariableNameLength);
|
||||
}
|
||||
|
||||
this.randomVariableNameSet.add(randomVariableName);
|
||||
|
||||
Reference in New Issue
Block a user