Skip to content

Instantly share code, notes, and snippets.

@73nko
Created January 16, 2020 20:41
Show Gist options
  • Save 73nko/376100bce1d7458364954a9b6a414d85 to your computer and use it in GitHub Desktop.
Save 73nko/376100bce1d7458364954a9b6a414d85 to your computer and use it in GitHub Desktop.
Generate a random ID without libraries
// 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