old_contents: import flask
  import passlib
  
  
  def get_hash_algorithm(hash_algorithm):
      """Returns a object with methods to encrypt a string and verify a hash.
  
      :hash_algorithm: a string object
      :returns: hash function
  
      """
  
      available_methods = {
          'SHA256': passlib.hash.sha256_crypt,
          'SHA512': passlib.hash.sha512_crypt,
      }
  
      if not isinstance(hash_algorithm, str):
          raise ValueError('The parameter "hash_algorithm" should be a string.')
  
      if hash_algorithm.upper() not in available_methods:
          raise ValueError('Invalid hash method.')
  
      return available_methods[hash_algorithm]
  
  
  def encrypt_password(plaintext):
      """Generate a hash based on current_app HASH_ALGORITHM.
  
      :plaintext: a string object.
      :returns: a string object.
  
      """
  
      method = get_hash_algorithm(flask.current_app.config['HASH_ALGORITHM'])
  
      return method.encrypt(
          plaintext, salt=flask.current_app.config['HASH_SALT'])
  
  
  def verify_passowrd(password, hash):
      """Verify if a hash was generated by the password specified.
  
      :password: a string object (plaintext).
      :hash: a string object.
      :returns: True or False.
  
      """
  
      method = get_hash_algorithm(flask.current_app.config['HASH_ALGORITHM'])
  
      return method.verify(password, hash)
  
new_contents: import flask
  from passlib import hash
  
  
  def get_hash_algorithm(hash_algorithm):
      """Returns a object with methods to encrypt a string and verify a hash.
  
      :hash_algorithm: a string object
      :returns: hash function
  
      """
  
      available_methods = {
          'SHA256': hash.sha256_crypt,
          'SHA512': hash.sha512_crypt,
      }
  
      if not isinstance(hash_algorithm, str):
          raise ValueError('The parameter "hash_algorithm" should be a string.')
  
      if hash_algorithm.upper() not in available_methods:
          raise ValueError('Invalid hash method.')
  
      return available_methods[hash_algorithm]
  
  
  def encrypt_password(plaintext):
      """Generate a hash based on current_app HASH_ALGORITHM.
  
      :plaintext: a string object.
      :returns: a string object.
  
      """
  
      method = get_hash_algorithm(flask.current_app.config['HASH_ALGORITHM'])
  
      return method.encrypt(
          plaintext, salt=flask.current_app.config['HASH_SALT'])
  
  
  def verify_passowrd(password, hash):
      """Verify if a hash was generated by the password specified.
  
      :password: a string object (plaintext).
      :hash: a string object.
      :returns: True or False.
  
      """
  
      method = get_hash_algorithm(flask.current_app.config['HASH_ALGORITHM'])
  
      return method.verify(password, hash)
  
subject: fix import