Skip to content

Commit b879769

Browse files
committed
codeql
1 parent a43543f commit b879769

File tree

1 file changed

+5
-3
lines changed
  • apps/array/src/shared/utils

1 file changed

+5
-3
lines changed

apps/array/src/shared/utils/id.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
import { randomBytes } from "node:crypto";
2-
31
export function randomSuffix(length = 8): string {
4-
return randomBytes(length).toString("hex").substring(0, length);
2+
const array = new Uint8Array(length);
3+
crypto.getRandomValues(array);
4+
return Array.from(array, (b) => b.toString(16).padStart(2, "0"))
5+
.join("")
6+
.substring(0, length);
57
}
68

79
export function generateId(prefix: string, length = 8): string {

0 commit comments

Comments
 (0)