Hello,

I use following snippet to hash a user password:

    crypto.randomBytes(32, function(err, buf) {
        if (err) throw err;
        user.salt = buf;
        crypto.pbkdf2(req.body.password, user.salt, 25000, 512, function(err, 
encodedPassword) {
            if (err) throw err;
            user.password = encodedPassword;
            user.save(function(err, user) {
                if (!err) return res.send(err, 500);
                return res.json(user);
            });
        }.bind(this));
    });


With buf.toString('base64') I can successfully encode the salt from a bin 
buffer object to a string. The same unfortunatly doesn't work on the 
derivedKey of pbkdf2.
This is some binary string which i can save to mongodb but I can't rebuilt 
it (hashing the user's login password gets always a different key).

So how can I encode the derivedKey of pbkd2 to a in javascript usable 
string (e.g. base64 or utf-8)?

Regards

-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

Reply via email to