bcrypt node.js (auto-gen a salt and hash)
问题 I am using the following code to hash (and hopefully salt) user passwords before I store them in my DB. // hash the password before the user is saved ConsultantSchema.pre('save', function(next) { var user = this; // hash the password only if the password has been changed or user is new if (!user.isModified('password')) return next(); // generate the hash bcrypt.hash(user.password, null, null, function(err, hash) { if (err) { logger.error("bcrypt.hash "+err); return next(err); } // change the