def compare_token(compare, token):
 (algorithm, srounds, salt, _) = compare.split(':')
 hashed = hash_token(token, salt=salt, rounds=int(srounds), algorithm=algorithm).encode('utf8')
 compare = compare.encode('utf8')
 if compare_digest(compare, hashed):
  return True
 return False

def compare_token ( compare , token ) : ( algorithm , srounds , salt , _ ) = compare . split ( ':' ) hashed = hash_token ( token , salt = salt , rounds = int ( srounds ) , algorithm = algorithm ) . encode ( 'utf8' ) compare = compare . encode ( 'utf8' ) if compare_digest ( compare , hashed ) : return True return False
compare a token with a hashed token uses the same algorithm and salt of the hashed token for comparison .