Use crypto to generate ids

This commit is contained in:
powermaker450 2024-08-27 01:31:24 -04:00
parent 33964ca6d1
commit a17b7595c1

View file

@ -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 {