"""Password hashing utilities using bcrypt."""

import bcrypt


class PasswordHasher:
	"""Handle password hashing and verification"""

	@staticmethod
	def hash_password(password: str) -> str:
		"""
		Hash a password using bcrypt.

		Args:
			password: Plain text password

		Returns:
			Hashed password
		"""
		password_bytes = password.encode("utf-8")
		salt = bcrypt.gensalt()
		hashed = bcrypt.hashpw(password_bytes, salt)
		return hashed.decode("utf-8")

	@staticmethod
	def verify_password(plain_password: str, hashed_password: str) -> bool:
		"""
		Verify a password against its hash.

		Args:
			plain_password: Plain text password to verify
			hashed_password: Hashed password to compare against

		Returns:
			True if password matches, False otherwise
		"""
		password_bytes = plain_password.encode("utf-8")
		hashed_bytes = hashed_password.encode("utf-8")
		return bcrypt.checkpw(password_bytes, hashed_bytes)
