Created
January 16, 2020 20:41
-
-
Save 73nko/376100bce1d7458364954a9b6a414d85 to your computer and use it in GitHub Desktop.
Generate a random ID without libraries
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
// random.ts | |
function randomId(): string { | |
const uint32 = window.crypto.getRandomValues(new Uint32Array(1))[0]; | |
return uint32.toString(16); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment