Use crypto to generate ids
This commit is contained in:
parent
33964ca6d1
commit
a17b7595c1
|
@ -1,5 +1,6 @@
|
|||
import fs from "fs";
|
||||
import { ServerSideReview, UserSideReview } from "../types";
|
||||
import * as crypto from "crypto";
|
||||
|
||||
export function checkFile(
|
||||
file: string,
|
||||
|
@ -23,9 +24,7 @@ export function checkFile(
|
|||
}
|
||||
|
||||
// Generates a unique 6-character ID
|
||||
export function generateId(): string {
|
||||
return Math.random().toString(36).replace("0.", "").substring(0, 6);
|
||||
}
|
||||
export const generateId = (): string => crypto.randomBytes(3).toString("hex");
|
||||
|
||||
export function appendId(userReview: UserSideReview): ServerSideReview {
|
||||
return {
|
||||
|
|
Loading…
Reference in a new issue