Attempt to resurrect qomet code - need some rewrite
[qomet.git] / utils / tokenGenerator.js
CommitLineData
e99c53fb
BA
1let TokenGen =
2{
3 rand: function()
4 {
5 return Math.random().toString(36).substr(2); // remove `0.`
6 },
7
8 generate: function(tlen)
9 {
10 var res = "";
11 var nbRands = Math.ceil(tlen/10); //10 = min length of a rand() string
12 for (var i = 0; i < nbRands; i++)
13 res += TokenGen.rand();
14 return res.substr(0, tlen);
15 },
16};
17
18module.exports = TokenGen;