added support for IE 11

This commit is contained in:
Alex Booker 2015-08-15 08:52:06 +01:00
parent 91fb2972b4
commit 1968f71abb

View File

@ -1,10 +1,11 @@
var passwordGenerator = (function() {
var generateRandomNum = function (max) {
if (!window.crypto || !window.crypto.getRandomValues) {
var crypto = window.crypto || window.msCrypto;
if (!crypto) {
throw new Error('Unsupported browser.');
}
var array = new Uint8Array(1);
window.crypto.getRandomValues(array);
crypto.getRandomValues(array);
var range = max + 1;
var max_range = 256;
if (array[0] >= Math.floor(max_range / range) * range)