mirror of
https://github.com/taobataoma/meanTorrent.git
synced 2026-01-28 18:19:23 +01:00
hash password with pbkdf2
This commit is contained in:
@@ -105,7 +105,7 @@ UserSchema.methods = {
|
||||
* @api public
|
||||
*/
|
||||
makeSalt: function() {
|
||||
return Math.round((new Date().valueOf() * Math.random())) + '';
|
||||
return crypto.randomBytes(16).toString('base64');
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -117,8 +117,9 @@ UserSchema.methods = {
|
||||
*/
|
||||
encryptPassword: function(password) {
|
||||
if (!password) return '';
|
||||
return crypto.createHmac('sha1', this.salt).update(password).digest('hex');
|
||||
salt = new Buffer(this.salt, 'base64');
|
||||
return crypto.pbkdf2Sync(password, salt, 10000, 64).toString('base64');
|
||||
}
|
||||
};
|
||||
|
||||
mongoose.model('User', UserSchema);
|
||||
mongoose.model('User', UserSchema);
|
||||
|
||||
Reference in New Issue
Block a user