mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-12-29 11:50:36 +01:00
19 lines
412 B
JavaScript
19 lines
412 B
JavaScript
'use strict';
|
|
|
|
const workerpool = require('workerpool');
|
|
const bcrypt = require('bcryptjs');
|
|
|
|
async function hash(password, rounds) {
|
|
const salt = await bcrypt.genSalt(parseInt(rounds, 10));
|
|
return await bcrypt.hash(password, salt);
|
|
}
|
|
|
|
async function compare(password, hash) {
|
|
return await bcrypt.compare(String(password || ''), String(hash || ''));
|
|
}
|
|
|
|
workerpool.worker({
|
|
hash: hash,
|
|
compare: compare,
|
|
});
|