Skip to content

Commit

Permalink
Fix code scanning alert no. 12: Insecure randomness (#1544)
Browse files Browse the repository at this point in the history
Signed-off-by: Priyankar Pal  <[email protected]>
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
  • Loading branch information
1 parent 22d3eed commit d7bfc6d
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 d7bfc6d

Please sign in to comment.