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

37 lines
760 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) {
10 years ago
var child = fork('./bcrypt', ['hash', rounds, password], {
silent: true
}),
response = '';
child.stdout.on('data', function(chunk) {
response += chunk.toString();
});
child.stdout.on('end', function() {
callback(null, response);
});
11 years ago
};
module.compare = function(password, hash, callback) {
10 years ago
var child = fork('./bcrypt', ['compare', password, hash], {
silent: true
}),
response = '';
child.stdout.on('data', function(chunk) {
response += chunk.toString();
});
child.stdout.on('end', function() {
callback(null, response === 'true');
});
11 years ago
};
10 years ago
return module;
})(exports);