crypto-browserify
Advanced tools
Comparing version 3.2.1 to 3.2.2
@@ -5,3 +5,3 @@ { | ||
"description": "partial implementation of crypto for the browser", | ||
"version": "3.2.1", | ||
"version": "3.2.2", | ||
"homepage": "https://github.com/dominictarr/crypto-browserify", | ||
@@ -8,0 +8,0 @@ "repository": { |
29
rng.js
(function() { | ||
var g = ('undefined' === typeof window ? global : window) || {} | ||
var foolBrowserify = require | ||
_crypto = ( | ||
g.crypto || g.msCrypto || foolBrowserify('crypto') | ||
) | ||
module.exports = function(size) { | ||
var bytes = new Buffer(size); //in browserify, this is an extended Uint8Array | ||
/* This will not work in older browsers. | ||
* See https://developer.mozilla.org/en-US/docs/Web/API/window.crypto.getRandomValues | ||
*/ | ||
crypto.getRandomValues(bytes); | ||
return bytes; | ||
// Modern Browsers | ||
if(_crypto.getRandomValues) { | ||
var bytes = new Buffer(size); //in browserify, this is an extended Uint8Array | ||
/* This will not work in older browsers. | ||
* See https://developer.mozilla.org/en-US/docs/Web/API/window.crypto.getRandomValues | ||
*/ | ||
_crypto.getRandomValues | ||
return bytes; | ||
} | ||
else if (_crypto.randomBytes) { | ||
return _crypto.randomBytes(size) | ||
} | ||
else | ||
throw new Error( | ||
'secure random number generation not supported by this browser\n'+ | ||
'use chrome, FireFox or Internet Explorer 11' | ||
) | ||
} | ||
}()) |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
34041
926
10