How is buffer stored?


I am trying to use crypt module of node.js to encrypt the password of the user. The function return me a buffer which I store in couchbase. I want to know how does the node SDK of couchbase store the buffers? When I am trying to verify if the passwords are correct or not, it doesn’t match. Please help me out.


Couchnode JSON encodes json objects. So if you are passing a NodeBuffer to a couchnode write operation, then it is JSON encoding the NodeBuffer object and not the contents of the buffer. You should be exporting the buffer to a string so that it can be JSON encoded properly.

var shasum = crypto.createHash('sha1'); shasum.update(password + salt);

var couchDoc =
“username”: “aUser”,
“hashedPassword”: shasum.digest(“hex”), // outputs the hash as a string of hex numbers
"salt": salt

cb.set(“User::aUser”, couchDoc, function() { });