1var crypto = require("crypto");
2var id = crypto.randomBytes(20).toString('hex');
3
4// "bb5dc8842ca31d4603d6aa11448d1654"
1function makeid() {
2 var text = "";
3 var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
4
5 for (var i = 0; i < 5; i++)
6 text += possible.charAt(Math.floor(Math.random() * possible.length));
7
8 return text;
9}
10
11console.log(makeid());
12
1 Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15);