Created
May 18, 2023 16:13
-
-
Save KooiInc/0e75891b552b5573f25585ebb8de2053 to your computer and use it in GitHub Desktop.
Create random number using crypto
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function randomNumber (min = 0, max = Number.MAX_SAFE_INTEGER) { | |
return Math.floor( ( [...crypto.getRandomValues( new Uint32Array(1))][0] / 2**32 ) * (max - min + 1) + min ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment