0 Star 0 Fork 17

easycode/NodeBB

forked from gitlabcc/NodeBB 
Create your Gitee Account
Explore and code with more than 12 million developers,Free private repositories !:)
Sign up
Clone or Download
bcrypt.js 662 Bytes
Copy Edit Raw Blame History
Barış Soner Uşaklı authored 2015-03-17 13:09 . shorter bcrypt
'use strict';
var bcrypt = require('bcryptjs'),
async = require('async');
process.on('message', function(msg) {
if (msg.type === 'hash') {
hashPassword(msg.password, msg.rounds);
} else if (msg.type === 'compare') {
bcrypt.compare(msg.password, msg.hash, done);
}
});
function hashPassword(password, rounds) {
async.waterfall([
function(next) {
bcrypt.genSalt(parseInt(rounds, 10), next);
},
function(salt, next) {
bcrypt.hash(password, salt, next);
}
], done);
}
function done(err, result) {
if (err) {
process.send({err: err.message});
return process.disconnect();
}
process.send({result: result});
process.disconnect();
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/maso/NodeBB.git
git@gitee.com:maso/NodeBB.git
maso
NodeBB
NodeBB
master

Search