import bcrypt from 'bcrypt';

const ROUNDS = 10;

export async function hashPassword(plain) {
  return bcrypt.hash(plain, ROUNDS);
}

export async function verifyPassword(plain, hash) {
  if (!hash || typeof hash !== 'string') return false;
  return bcrypt.compare(plain, hash);
}
