Created
May 27, 2011 20:55
-
-
Save zed0/996145 to your computer and use it in GitHub Desktop.
Getting: 'Error: Not initialized' on line 15
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var crypto = require('crypto'); | |
var fs = require('fs'); | |
var dir = fs.readdirSync('.'); | |
for(var i=0; i<dir.length; ++i) | |
{ | |
var filename = dir[i]; | |
if(fs.statSync(filename).isFile()) { | |
var md5 = crypto.createHash('md5'); | |
var s = fs.ReadStream(filename); | |
s.on('data', function(data) { | |
md5.update(data); | |
}); | |
s.on('end', function() { | |
console.log(md5.digest('hex')); | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Full output:
89377bc3c57dfd486724018703295371
/home/zed0/test.js:15
console.log(md5.digest('hex'));
^
Error: Not initialized
at [object Object]. (/home/zed0/test.js:15:20)
at [object Object].emit (events.js:39:17)
at afterRead (fs.js:843:12)