From df1d70e73f9f1c29c52684cb1338d872983302d7 Mon Sep 17 00:00:00 2001 From: Adrian Kunz Date: Mon, 13 Nov 2023 11:16:01 +0100 Subject: [PATCH] fix(frontend): Better random task IDs --- frontend/src/app/assignment/services/task.service.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/frontend/src/app/assignment/services/task.service.ts b/frontend/src/app/assignment/services/task.service.ts index ce046b4a7..f49c6f22a 100644 --- a/frontend/src/app/assignment/services/task.service.ts +++ b/frontend/src/app/assignment/services/task.service.ts @@ -31,7 +31,10 @@ export class TaskService { } generateID(): string { - return (Date.now() + Math.random()).toString(36).replace('.', 'T').substring(0, 12); + // generate a random hex string with 16 characters (64 bit) securely + const array = new Uint8Array(8); + crypto.getRandomValues(array); + return Array.from(array, (byte) => byte.toString(16).padStart(2, '0')).join(''); } createPointsCache(tasks: Task[], evaluations: Record): Record {