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 a43543f commit b879769Copy full SHA for b879769
apps/array/src/shared/utils/id.ts
@@ -1,7 +1,9 @@
1
-import { randomBytes } from "node:crypto";
2
-
3
export function randomSuffix(length = 8): string {
4
- return randomBytes(length).toString("hex").substring(0, length);
+ const array = new Uint8Array(length);
+ crypto.getRandomValues(array);
+ return Array.from(array, (b) => b.toString(16).padStart(2, "0"))
5
+ .join("")
6
+ .substring(0, length);
7
}
8
9
export function generateId(prefix: string, length = 8): string {
0 commit comments