projects
/
vchess.git
/ blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
blame
|
history
|
raw
|
HEAD
Separate client and server codes. Keep everything in one git repo for simplicity
[vchess.git]
/
server
/
utils
/
tokenGenerator.js
1
function
randString
()
2
{
3
return
Math
.
random
().
toString
(
36
).
substr
(
2
);
// remove `0.`
4
}
5
6
module
.
exports
=
function
(
tlen
)
7
{
8
let
res
=
""
;
9
let
nbRands
=
Math
.
ceil
(
tlen
/10); /
/
10
=
min length
of
a
rand
()
string
10
for
(
let
i
=
0
;
i
<
nbRands
;
i
++)
11
res
+=
randString
();
12
return
res
.
substr
(
0
,
tlen
);
13
}