def verifyPassword(password, hash):
 try:
  (digestname, iterations, salt, pwHash) = hash.split(Delimiter)
 except ValueError:
  raise ValueError(u"Expected hash encoded password in format 'digestmod{0}iterations{0}salt{0}hashed_password".format(Delimiter))
 if (digestname not in Hashes.keys()):
  raise ValueError(u"Unsupported hash algorithm '{0}' for hash encoded password '{1}'.".format(digestname, hash))
 iterations = int(iterations)
 salt = base64.b64decode(salt.encode(u'ascii'))
 pwHash = base64.b64decode(pwHash.encode(u'ascii'))
 password = password.encode(u'utf-8')
 return (pwHash == pbkdf2(password, salt, iterations, Hashes[digestname]))

def verifyPassword ( password , hash ) : try : ( digestname , iterations , salt , pwHash ) = hash . split ( Delimiter ) except ValueError : raise ValueError ( u"Expected hash encoded password in format 'digestmod{0}iterations{0}salt{0}hashed_password" . format ( Delimiter ) ) if ( digestname not in Hashes . keys ( ) ) : raise ValueError ( u"Unsupported hash algorithm '{0}' for hash encoded password '{1}'." . format ( digestname , hash ) ) iterations = int ( iterations ) salt = base64 . b64decode ( salt . encode ( u'ascii' ) ) pwHash = base64 . b64decode ( pwHash . encode ( u'ascii' ) ) password = password . encode ( u'utf-8' ) return ( pwHash == pbkdf2 ( password , salt , iterations , Hashes [ digestname ] ) )
module function to verify a password against a hash encoded password .