1function generate_token(length){
2 //edit the token allowed characters
3 var a = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890".split("");
4 var b = [];
5 for (var i=0; i<length; i++) {
6 var j = (Math.random() * (a.length-1)).toFixed(0);
7 b[i] = a[j];
8 }
9 return b.join("");
10}
11generate_token(32); //returns "qweQj4giRJSdMNzB8g1XIa6t3YtRIHPH"
12