Skip to content

Commit

Permalink
randomBytes
Browse files Browse the repository at this point in the history
  • Loading branch information
thecarlo committed Apr 30, 2024
1 parent b3a684b commit 017aaa2
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/functions/passphrase/dice/rollDie.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
import { randomBytes } from 'crypto';

export const rollDie = (): number => {
return Math.floor(Math.random() * 6) + 1;
const buffer = randomBytes(4);

const randomNumber = buffer.readUInt32BE(0);

return (randomNumber % 6) + 1;
};

0 comments on commit 017aaa2

Please # to comment.