alapa
Version:
A cutting-edge web development framework designed to revolutionize the way developers build modern web applications.
27 lines (26 loc) • 1.04 kB
JavaScript
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.HashPassword = void 0;
const password_hash_1 = __importDefault(require("password-hash"));
class HashPassword {
// Encrypt the password by hashing it with a salt using bcrypt
static async encrypt(password) {
return password_hash_1.default.generate(password);
}
// Verify that the password matches the hashed password
static async verify(password, hashedPassword) {
return password_hash_1.default.verify(password, hashedPassword);
}
// Hash the password (alias for encrypt)
static hash(password) {
return this.encrypt(password);
}
// Validate the password against the hashed password (alias for verify)
static validate(password, hashedPassword) {
return this.verify(password, hashedPassword);
}
}
exports.HashPassword = HashPassword;
;