Created
January 15, 2020 12:42
-
-
Save stefanfrede/73e7dff5611e3f4101babf5bc78d6281 to your computer and use it in GitHub Desktop.
Generate a unique id in the browser without a library
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 randomId() { | |
const uint32 = window.crypto.getRandomValues(new Uint32Array(1))[0]; | |
return uint32.toString(16); | |
} | |
const rid = randomId(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment