Skip to content

Commit

Permalink
fix(frontend): Better random task IDs
Browse files Browse the repository at this point in the history
  • Loading branch information
Clashsoft committed Nov 13, 2023
1 parent f701f88 commit df1d70e
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion frontend/src/app/assignment/services/task.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, Evaluation | CreateEvaluationDto>): Record<string, number> {
Expand Down

0 comments on commit df1d70e

Please sign in to comment.