harmonize different ID types, improved the prefixes

This commit is contained in:
Peter 'Pita' Martischka 2011-08-10 14:24:21 +01:00
parent f6b87daa27
commit 292c68a0a5
5 changed files with 54 additions and 64 deletions

View file

@ -380,12 +380,14 @@ function listSessionsWithDBKey (dbkey, callback)
*/
function randomString(len)
{
// use only numbers and lowercase letters
var pieces = [];
for(var i=0;i<len;i++) {
pieces.push(Math.floor(Math.random()*36).toString(36).slice(-1));
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 pieces.join('');
return randomstring;
}
//checks if a number is an int