Merge pull request #366 from booo/master

move randomString function into a module
This commit is contained in:
Peter 'Pita' Martischka 2012-01-30 01:58:28 -08:00
commit aeea061f69
8 changed files with 26 additions and 90 deletions

View file

@ -0,0 +1,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;