Merge pull request #207 from openpgpjs/ie11

Fix random.js for IE11
This commit is contained in:
Tankred Hase 2014-04-02 19:52:13 +02:00
commit 4bf2fbf985

View File

@ -79,8 +79,10 @@ module.exports = {
if (!(buf instanceof Uint8Array)) {
throw new Error('Invalid type: buf not an Uint8Array');
}
if (typeof window !== 'undefined' && window.crypto) {
if (typeof window !== 'undefined' && window.crypto && window.crypto.getRandomValues) {
window.crypto.getRandomValues(buf);
} else if (typeof window !== 'undefined' && typeof window.msCrypto === 'object' && typeof window.msCrypto.getRandomValues === 'function') {
window.msCrypto.getRandomValues(buf);
} else if (nodeCrypto) {
var bytes = nodeCrypto.randomBytes(buf.length);
buf.set(bytes);