const crypto = require("node:crypto"); const bcrypt = require("bcryptjs"); function sha256Hex(input) { return crypto.createHash("sha256").update(input).digest("hex"); } function randomRefreshToken() { return crypto.randomBytes(32).toString("base64url"); } async function hashPassword(password) { const saltRounds = 12; return bcrypt.hash(password, saltRounds); } async function verifyPassword(password, passwordHash) { return bcrypt.compare(password, passwordHash); } module.exports = { hashPassword, randomRefreshToken, sha256Hex, verifyPassword, };