You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
nodebb/src/password.js

34 lines
833 B
JavaScript

11 years ago
'use strict';
(function (module) {
10 years ago
var fork = require('child_process').fork;
11 years ago
module.hash = function (rounds, password, callback) {
forkChild({type: 'hash', rounds: rounds, password: password}, callback);
11 years ago
};
module.compare = function (password, hash, callback) {
forkChild({type: 'compare', password: password, hash: hash}, callback);
};
function forkChild(message, callback) {
9 years ago
var forkProcessParams = {};
if (global.v8debug || parseInt(process.execArgv.indexOf('--debug'), 10) !== -1) {
9 years ago
forkProcessParams = {execArgv: ['--debug=' + (5859), '--nolazy']};
}
var child = fork('./bcrypt', [], forkProcessParams);
10 years ago
child.on('message', function (msg) {
if (msg.err) {
return callback(new Error(msg.err));
}
10 years ago
callback(null, msg.result);
10 years ago
});
child.send(message);
}
11 years ago
10 years ago
return module;
8 years ago
}(exports));