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

24 lines
547 B

3 years ago
const passwordHashOld = require("password-hash");
const bcrypt = require("bcryptjs");
const saltRounds = 10;
exports.generate = function (password) {
return bcrypt.hashSync(password, saltRounds);
};
exports.verify = function (password, hash) {
if (isSHA1(hash)) {
return passwordHashOld.verify(password, hash);
}
3 years ago
return bcrypt.compareSync(password, hash);
};
function isSHA1(hash) {
return (typeof hash === "string" && hash.startsWith("sha1"));
}
exports.needRehash = function (hash) {
return isSHA1(hash);
};