Skip to content

Commit

Permalink
CQI-147: change math random to getSafeRandomNumber
Browse files Browse the repository at this point in the history
  • Loading branch information
lruzicki committed Apr 30, 2024
1 parent 859860c commit 75e93f1
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/helpers/passwordGenerator.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export const passwordGenerator = (options) => {

// Fill the rest of the password with random characters
for (let i = categoriesArray.length; i < length; i++) {
const randomCategory = categoriesArray[Math.floor(Math.random() * categoriesArray.length)];
const randomCategory = categoriesArray[getSafeRandomNumberArray(1, categoriesArray.length)];
password += getRandomOfType(randomCategory);
}

Expand All @@ -43,7 +43,7 @@ export const passwordGenerator = (options) => {
};

function shuffle(str) {
return str.split('').sort(() => Math.random() - 0.5).join('');
return str.split('').sort(() => getSafeRandomNumberArray(1, 3) - 0.5).join('');
}

function getRandomOfType(charset) {
Expand Down

0 comments on commit 75e93f1

Please sign in to comment.