Skip to content

Instantly share code, notes, and snippets.

@zed0
Created May 27, 2011 20:55
Show Gist options
  • Save zed0/996145 to your computer and use it in GitHub Desktop.
Save zed0/996145 to your computer and use it in GitHub Desktop.
Getting: 'Error: Not initialized' on line 15
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'));
});
}
}
@zed0
Copy link
Author

zed0 commented May 27, 2011

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment