mirror of
https://github.com/privacyguides/privacyguides.org.git
synced 2024-12-29 17:36:28 -05:00
added support for IE 11
This commit is contained in:
parent
91fb2972b4
commit
1968f71abb
@ -1,10 +1,11 @@
|
|||||||
var passwordGenerator = (function() {
|
var passwordGenerator = (function() {
|
||||||
var generateRandomNum = function (max) {
|
var generateRandomNum = function (max) {
|
||||||
if (!window.crypto || !window.crypto.getRandomValues) {
|
var crypto = window.crypto || window.msCrypto;
|
||||||
|
if (!crypto) {
|
||||||
throw new Error('Unsupported browser.');
|
throw new Error('Unsupported browser.');
|
||||||
}
|
}
|
||||||
var array = new Uint8Array(1);
|
var array = new Uint8Array(1);
|
||||||
window.crypto.getRandomValues(array);
|
crypto.getRandomValues(array);
|
||||||
var range = max + 1;
|
var range = max + 1;
|
||||||
var max_range = 256;
|
var max_range = 256;
|
||||||
if (array[0] >= Math.floor(max_range / range) * range)
|
if (array[0] >= Math.floor(max_range / range) * range)
|
||||||
|
Loading…
Reference in New Issue
Block a user