Skip to content

Commit

Permalink
Fix code scanning alert no. 7: 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>
  • Loading branch information
drzo and github-advanced-security[bot] authored Oct 25, 2024
1 parent 5f07491 commit 322933c
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions influent-client/influent-clientjs/src/scripts/lib/util/GUID.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,14 @@ define(

guid.generateGuid = function () {
var result = '';
for (var i = 0; i < 32; i++) {
if (i === 8 || i === 12 || i === 16 || i === 20) {
result = result + '-';
var array = new Uint8Array(16);
window.crypto.getRandomValues(array);
for (var i = 0; i < array.length; i++) {
if (i === 4 || i === 6 || i === 8 || i === 10) {
result += '-';
}
result = result + Math.floor(Math.random() * 16).toString(16).toUpperCase();
result += array[i].toString(16).padStart(2, '0').toUpperCase();
}

return result;
};

Expand Down

0 comments on commit 322933c

Please sign in to comment.