summaryrefslogtreecommitdiff
path: root/src/node/utils/randomstring.js
blob: 4c1bba244c95b4ce033126ada2c56cb429dda945 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
/**
 * Generates a random String with the given length. Is needed to generate the Author, Group, readonly, session Ids
 */
var randomString = function randomString(len)
{
  var chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
  var randomstring = '';
  for (var i = 0; i < len; i++)
  {
    var rnum = Math.floor(Math.random() * chars.length);
    randomstring += chars.substring(rnum, rnum + 1);
  }
  return randomstring;
};

module.exports = randomString;