Skip to content

Commit

Permalink
fix: use crypto random to generate salt
Browse files Browse the repository at this point in the history
  • Loading branch information
davidyuk committed Aug 2, 2022
1 parent 0478eed commit 88dcf38
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/utils/crypto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ export function isAddressValid(
* @returns random salt
*/
export function genSalt(): number {
return Math.floor(Math.random() * Math.floor(Number.MAX_SAFE_INTEGER));
const [random] = new BigUint64Array(nacl.randomBytes(8).buffer);
return Number(random % BigInt(Number.MAX_SAFE_INTEGER));
}

/**
Expand Down

0 comments on commit 88dcf38

Please sign in to comment.