From 9e75bc7642aff9cdd427feef1d07fd0a700236b2 Mon Sep 17 00:00:00 2001 From: Slixor Date: Fri, 9 Mar 2018 20:40:08 +0000 Subject: [PATCH] Fixed IE 11 Password Generation IE only supports window.msCrypto as opposed to window.crypto. This allows support for both functions across all browsers. --- app/src/Upload/Settings.vue | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/app/src/Upload/Settings.vue b/app/src/Upload/Settings.vue index 90ff4a1..ec8d512 100644 --- a/app/src/Upload/Settings.vue +++ b/app/src/Upload/Settings.vue @@ -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) {