+24
| var md5 = require('./index'); | ||
| console.log('md5 (1) ' + md5('./README.md')); | ||
| md5.async('./README.md', function (data) { | ||
| console.log('md5 (2) ' + data); | ||
| }); | ||
| md5.async('./README.md', function (data) { | ||
| console.log('md5 (3) ' + data); | ||
| }, true); | ||
| // errors | ||
| // non-strict: will pass through an error to `data` | ||
| md5.async('./null', function (data) { | ||
| console.log('md5 (4) ' + data); | ||
| }); | ||
| // strict: will throw an error | ||
| md5.async('./null', function (data) { | ||
| console.log('md5 (5) ' + data); | ||
| }, true); | ||
+21
-2
@@ -23,8 +23,27 @@ // The MIT License (MIT) | ||
| "use strict"; | ||
| var crypto = require('crypto'); | ||
| var fs = require('fs'); | ||
| module.exports = function (filename) { | ||
| var crypto = require('crypto'); | ||
| var fs = require('fs'); | ||
| var sum = crypto.createHash('md5'); | ||
| sum.update(fs.readFileSync(filename)); | ||
| return sum.digest('hex'); | ||
| } | ||
| // if `strict` then throw error otherwise pass error through | ||
| module.exports.async = function (filename, callback, strict) { | ||
| fs.readFile(filename, function (error, data) { | ||
| if (error) { | ||
| if (strict) { | ||
| throw error; | ||
| } else { | ||
| return callback(error); | ||
| } | ||
| } else { | ||
| var sum = crypto.createHash('md5'); | ||
| sum.update(data); | ||
| return callback(sum.digest('hex')); | ||
| } | ||
| }); | ||
| } |
+7
-1
| { | ||
| "name": "md5-file", | ||
| "main": "index.js", | ||
| "version": "1.0.1", | ||
| "files" : [ | ||
| "index.js", "test.js" | ||
| ], | ||
| "version": "1.1.0", | ||
| "description": "return an md5sum of a given file", | ||
@@ -24,3 +27,6 @@ "keywords": [ | ||
| "email": "roryrjb@gmail.com" | ||
| }, | ||
| "scripts" : { | ||
| "test" : "node test" | ||
| } | ||
| } |
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
3275
47.32%4
33.33%61
125.93%2
100%