Skip to content

Instantly share code, notes, and snippets.

@dongnguyenltqb
Forked from 6174/Random-string
Last active November 10, 2019 08:10
Show Gist options
  • Save dongnguyenltqb/0ac9d26e986a471971c732f89b1c1ffc to your computer and use it in GitHub Desktop.
Save dongnguyenltqb/0ac9d26e986a471971c732f89b1c1ffc to your computer and use it in GitHub Desktop.
Generate a random string in JavaScript In a short and fast way!
//http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript
Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15);
or just crypto
const crypto = require("crypto");
const id = crypto.randomBytes(16).toString("hex");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment