fix: eliminate division on crypto random in getSafeRandomFloat
This commit is contained in:
@@ -4511,18 +4511,18 @@ this._secureLog('info', '🔒 Enhanced Mutex system fully initialized and valida
|
||||
return min + randomValue;
|
||||
}
|
||||
|
||||
getSafeRandomFloat(minFloat, maxFloat, scale = 1000) {
|
||||
getSafeRandomFloat(minFloat, maxFloat, steps = 1000) {
|
||||
if (typeof minFloat !== 'number' || typeof maxFloat !== 'number') {
|
||||
throw new Error('getSafeRandomFloat requires numeric min and max');
|
||||
}
|
||||
if (minFloat >= maxFloat) {
|
||||
throw new Error('minFloat must be less than maxFloat');
|
||||
}
|
||||
const randomIndex = this.getSafeRandomInt(0, steps);
|
||||
|
||||
const minInt = Math.round(minFloat * scale);
|
||||
const maxInt = Math.round(maxFloat * scale);
|
||||
const intVal = this.getSafeRandomInt(minInt, maxInt);
|
||||
return intVal / scale;
|
||||
const step = (maxFloat - minFloat) / steps;
|
||||
|
||||
return minFloat + (randomIndex * step);
|
||||
}
|
||||
|
||||
generateFingerprintMask() {
|
||||
|
||||
Reference in New Issue
Block a user