input: Write a python function to generate a hash of a password using a specified algorithm.
  assert PasswordHasher('sha256').generate_hash('password123') == 'ef92b778bafe771e89245b89ecbc1b39f065fabd74912fabc7c0e8a2e3d7b2a5'
  assert PasswordHasher('md5').generate_hash('password123') == '482c811da5d5b4bc6d497ffa98491e38'
  assert PasswordHasher('sha1').generate_hash('password123') == 'cbfdac6008f9cab4083784cbd1874f76618d2a97'
output: import hashlib
  
  class PasswordHasher:
      def __init__(self, algorithm):
          self.algorithm = algorithm
  
      def generate_hash(self, password):
          hash_func = hashlib.new(self.algorithm)
          hash_func.update(password.encode('utf-8'))
          return hash_func.hexdigest()