Skip to content

Commit

Permalink
Fix code scanning alert no. 12: Insecure randomness
Browse files Browse the repository at this point in the history
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Signed-off-by: Priyankar Pal  <[email protected]>
  • Loading branch information
1 parent ee6d5fd commit 2873998
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/plays/password-generator/PasswordGenerator.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ function PasswordGenerator(props) {

// generate a random number within limit which is provided
const randomNumberGenerator = (limit) => {
const array = new Uint32Array(1);
let result = 0;
while (limit) {
result = Math.floor(Math.random() * Math.floor(Math.random() * 100));
window.crypto.getRandomValues(array);
result = array[0] % limit;
if (result < limit) return result;

continue;
}
};

Expand Down

0 comments on commit 2873998

Please sign in to comment.