brainpicture / hashlib

lib for node which makes hashes
nodejs.ru
165 stars 35 forks source link

Binary data not hashed correctly #14

Open kornelski opened 13 years ago

kornelski commented 13 years ago
fs.readFile(file_path, undefined, function(err, data) {
    console.log(hashlib.sha1(data));
});

If file at file_path contains ASCII, the hash is correct. However, binary files get wrong hash.

Could you add support for this case? (as far as I understand, in this case node.js returns data in raw encoding, so sha1() could read it properly). Alternatively, add sha1_file()?

msm595 commented 13 years ago

I would like this to be resolved as well. :)

poelzi commented 13 years ago

this one cost me like half a day :-(

> hashlib.sha256(buffalo.serialize([[909, true]]))
'1f379a96dc47a2244a5c888bd7e9b5b85819b33f3e8dfc1a32f4976847fc53de'
> hashlib.sha256(buffalo.serialize([[910, true]]))
'1f379a96dc47a2244a5c888bd7e9b5b85819b33f3e8dfc1a32f4976847fc53de'
> hashlib.sha256(buffalo.serialize([[910, true]]).toString())
'1f379a96dc47a2244a5c888bd7e9b5b85819b33f3e8dfc1a32f4976847fc53de'
> hashlib.sha256(buffalo.serialize([[909, true]]).toString())
'1f379a96dc47a2244a5c888bd7e9b5b85819b33f3e8dfc1a32f4976847fc53de'
poelzi commented 13 years ago

https://github.com/brainfucker/hashlib/pull/21