Revise server code + a few fixes in trnalsations and ComputerGame
[vchess.git] / server / utils / tokenGenerator.js
CommitLineData
badeb466 1function randString()
0bd5933d 2{
dac39588 3 return Math.random().toString(36).substr(2); // remove `0.`
badeb466 4}
0bd5933d 5
866842c3 6module.exports = function(tokenLength)
badeb466 7{
dac39588 8 let res = "";
866842c3
BA
9 // 10 = min length of a rand() string
10 let nbRands = Math.ceil(tokenLength/10);
dac39588
BA
11 for (let i = 0; i < nbRands; i++)
12 res += randString();
866842c3 13 return res.substr(0, tokenLength);
0bd5933d 14}