@gen.coroutine
def ValidatePassword(client, user_id, password, salt, expected_hash):
 actual_hash = HashPassword(password, salt)
 guess_id = Guess.ConstructGuessId('pw', user_id)
 if (not (yield Guess.CheckGuessLimit(client, guess_id, _MAX_PASSWORD_GUESSES))):
  raise PermissionError(TOO_MANY_GUESSES_ERROR)
 if (not web._time_independent_equals(actual_hash, expected_hash)):
  (yield Guess.ReportIncorrectGuess(client, guess_id))
  raise PermissionError(_PASSWORD_MISMATCH)

@ gen . coroutine def ValidatePassword ( client , user_id , password , salt , expected_hash ) : actual_hash = HashPassword ( password , salt ) guess_id = Guess . ConstructGuessId ( 'pw' , user_id ) if ( not ( yield Guess . CheckGuessLimit ( client , guess_id , _MAX_PASSWORD_GUESSES ) ) ) : raise PermissionError ( TOO_MANY_GUESSES_ERROR ) if ( not web . _time_independent_equals ( actual_hash , expected_hash ) ) : ( yield Guess . ReportIncorrectGuess ( client , guess_id ) ) raise PermissionError ( _PASSWORD_MISMATCH )
hashes the given users password using the given salt .