From 8f6a5b547454d62f21a02ab451db1b5450efc846 Mon Sep 17 00:00:00 2001 From: stringsplit <77242831+nbitzz@users.noreply.github.com> Date: Sun, 1 Oct 2023 17:45:07 -0700 Subject: [PATCH] swap to crypto.randomInt over Math.random --- src/server/lib/files.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/server/lib/files.ts b/src/server/lib/files.ts index 34d5b67..e264495 100644 --- a/src/server/lib/files.ts +++ b/src/server/lib/files.ts @@ -2,6 +2,7 @@ import axios from "axios"; import Discord, { Client, TextBasedChannel } from "discord.js"; import { readFile, writeFile } from "fs"; import { Readable } from "node:stream"; +import crypto from "node:crypto"; import { files } from "./accounts"; import * as Accounts from "./accounts"; @@ -16,7 +17,7 @@ export type FileVisibility = "public" | "anonymous" | "private" export function generateFileId(length:number=5) { let fid = "" for (let i = 0; i < length; i++) { - fid += alphanum[Math.floor(Math.random()*alphanum.length)] + fid += alphanum[crypto.randomInt(0,alphanum.length)] } return fid }