import bcrypt from 'bcryptjs'

const SALT_ROUNDS = 12

// Hash a plaintext password with bcrypt.
export const hashPassword = async (plain: string): Promise<string> => bcrypt.hash(plain, SALT_ROUNDS)

// Compare a plaintext password with a bcrypt hash.
export const comparePassword = async (plain: string, hash: string): Promise<boolean> =>
  bcrypt.compare(plain, hash)
