Fixed IE 11 Password Generation

IE only supports window.msCrypto as opposed to window.crypto.  This allows support for both functions across all browsers.
This commit is contained in:
Slixor
2018-03-09 20:40:08 +00:00
parent 7552771e69
commit 9e75bc7642

View File

@@ -29,11 +29,19 @@
_pattern : /[A-Z0-9_\-\+\!]/,
_getRandomByte: function() {
const result = new Uint8Array(1);
window.crypto.getRandomValues(result);
var fixedcrypto = window.msCrypto;
if (!fixedcrypto) {
var fixedcrypto = window.crypto;
}
fixedcrypto.getRandomValues(result);
return result[0];
},
generate: function(length) {
if(!window.crypto || !window.crypto.getRandomValues) return '';
var fixedcrypto2 = window.msCrypto;
if (!fixedcrypto2) {
var fixedcrypto2 = window.crypto;
}
if(!fixedcrypto2 || !fixedcrypto2.getRandomValues) return '';
return Array.apply(null, {'length': length}).map(function() {
let result;
while(true) {