dongnguyenltqb
6/15/2018 - 4:45 AM

Generate a random string in JavaScript In a short and fast way!

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");