We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 9e0580a commit d2fca54Copy full SHA for d2fca54
infrastructure/w3id/src/utils/rand.ts
@@ -10,9 +10,12 @@ export function generateRandomAlphaNum(length = 16): string {
10
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
11
let result = "";
12
const charsLength = chars.length;
13
+ const randomValues = new Uint32Array(length);
14
+
15
+ crypto.getRandomValues(randomValues);
16
17
for (let i = 0; i < length; i++) {
- result += chars.charAt(Math.floor(Math.random() * charsLength));
18
+ result += chars.charAt(randomValues[i] % charsLength);
19
}
20
21
return result;
0 commit comments