Files
NodeBB/src/password.js

37 lines
760 B
JavaScript
Raw Normal View History

2014-08-12 21:41:23 -04:00
'use strict';
(function(module) {
2014-10-07 19:49:18 -04:00
var fork = require('child_process').fork;
2014-08-12 21:41:23 -04:00
module.hash = function(rounds, password, callback) {
2014-10-07 19:49:18 -04:00
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);
});
2014-08-12 21:41:23 -04:00
};
module.compare = function(password, hash, callback) {
2014-10-07 19:49:18 -04:00
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');
});
2014-08-12 21:41:23 -04:00
};
2014-10-07 19:49:18 -04:00
return module;
})(exports);