diff --git a/src/functions/passphrase/dice/rollDie.ts b/src/functions/passphrase/dice/rollDie.ts index 1a50374..2082b1f 100644 --- a/src/functions/passphrase/dice/rollDie.ts +++ b/src/functions/passphrase/dice/rollDie.ts @@ -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; };