mirror of
https://github.com/privacyguides/privacyguides.org.git
synced 2024-12-23 22:49:42 -05:00
use secure random number generator
This commit is contained in:
parent
e13220c2fb
commit
78634330de
@ -1,6 +1,12 @@
|
||||
var passwordGenerator = (function() {
|
||||
var generateRandomNum = function (max) {
|
||||
return Math.floor(Math.random() * max);
|
||||
var array = new Uint8Array(1);
|
||||
window.crypto.getRandomValues(array);
|
||||
var range = max + 1;
|
||||
var max_range = 256;
|
||||
if (array[0] >= Math.floor(max_range / range) * range)
|
||||
return generateRandomNum(max);
|
||||
return (array[0] % range);
|
||||
};
|
||||
|
||||
var generatePassword = function (options) {
|
||||
|
Loading…
Reference in New Issue
Block a user