diff --git a/src/crypto-browser.js b/src/crypto-browser.js index 9035e8ba..e18944f5 100644 --- a/src/crypto-browser.js +++ b/src/crypto-browser.js @@ -15,6 +15,16 @@ function getWebCrypto () { return window.msCrypto.subtle } } + + if (typeof self !== 'undefined') { + if (self.crypto) { + return self.crypto.subtle || self.crypto.webkitSubtle + } + + if (self.msCrypto) { + return self.msCrypto.subtle + } + } } function webCryptoHash (type) { diff --git a/src/crypto-sha1-2-browser.js b/src/crypto-sha1-2-browser.js index 652cca93..3dbb4f8c 100644 --- a/src/crypto-sha1-2-browser.js +++ b/src/crypto-sha1-2-browser.js @@ -14,6 +14,16 @@ function getWebCrypto () { return window.msCrypto.subtle } } + + if (typeof self !== 'undefined') { + if (self.crypto) { + return self.crypto.subtle || self.crypto.webkitSubtle + } + + if (self.msCrypto) { + return self.msCrypto.subtle + } + } } function webCryptoHash (type) {