Revamp array filtering

Replaced fakeMd5 with new Jua.randomId
Cleanup more code
This commit is contained in:
djmaze 2020-10-02 23:54:15 +02:00
parent 9992b20163
commit c3a2da65df
23 changed files with 130 additions and 289 deletions

14
vendors/jua/jua.js vendored
View file

@ -488,13 +488,7 @@
*/
addNewFile(oFileInfo)
{
let iLen = 16,
fakeMd5 = '';
while (iLen--)
fakeMd5 += '0123456789abcdefghijklmnopqrstuvwxyz'.substr(Math.round(Math.random() * 36), 1);
this.addFile('jua-uid-' + fakeMd5 + '-' + (Date.now().toString()), oFileInfo);
this.addFile('jua-uid-' + Jua.randomId(16) + '-' + (Date.now().toString()), oFileInfo);
}
/**
@ -516,6 +510,12 @@
}
}
Jua.randomId = len => {
let arr = new Uint8Array((len || 32) / 2);
crypto.getRandomValues(arr);
return arr.map(dec => dec.toString(16).padStart(2,'0')).join('');
}
/**
* @type {number}
*/