Created
January 24, 2020 18:57
-
-
Save earthboundkid/3c40e4d2d5529e05f65676bb054758d8 to your computer and use it in GitHub Desktop.
Generate random hex digits
This file contains hidden or 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 randomHex(n) { | |
let bytes = new Uint8Array(n); | |
crypto.getRandomValues(bytes); | |
return Array.from(bytes).map(b => b.toString(16).padStart(2, '0')).join(''); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment