original_docstring: Check if given token is valid time-based one-time password for given
      secret.
  
      :param token: token which is being checked
      :type token: int or str
      :param secret: secret for which the token is being checked
      :type secret: str
      :param digest_method: method of generating digest (hashlib.sha1 by default)
      :type digest_method: callable
      :param token_length: length of the token (6 by default)
      :type token_length: int
      :param interval_length: length of TOTP interval (30 seconds by default)
      :type interval_length: int
      :param clock: time in epoch seconds to generate totp for, default is now
      :type clock: int
      :param window: compensate for clock skew, number of intervals to check on
          each side of the current time. (default is 0 - only check the current
          clock time)
      :type window: int (positive)
      :return: True, if is valid token, False otherwise
      :rtype: bool
  
      >>> secret = b'MFRGGZDFMZTWQ2LK'
      >>> token = get_totp(secret)
      >>> valid_totp(token, secret)
      True
      >>> valid_totp(token+1, secret)
      False
      >>> token = get_totp(secret, as_string=True)
      >>> valid_totp(token, secret)
      True
      >>> valid_totp(token + b'1', secret)
      False
      
docstring: Check if given token is valid time-based one-time password for given
  secret.
docstring_tokens: Check if given token is valid time - based one - time password for given secret .
code: def valid_totp(
          token,
          secret,
          digest_method=hashlib.sha1,
          token_length=6,
          interval_length=30,
          clock=None,
          window=0,
  ):
      """Check if given token is valid time-based one-time password for given
      secret.
  
      :param token: token which is being checked
      :type token: int or str
      :param secret: secret for which the token is being checked
      :type secret: str
      :param digest_method: method of generating digest (hashlib.sha1 by default)
      :type digest_method: callable
      :param token_length: length of the token (6 by default)
      :type token_length: int
      :param interval_length: length of TOTP interval (30 seconds by default)
      :type interval_length: int
      :param clock: time in epoch seconds to generate totp for, default is now
      :type clock: int
      :param window: compensate for clock skew, number of intervals to check on
          each side of the current time. (default is 0 - only check the current
          clock time)
      :type window: int (positive)
      :return: True, if is valid token, False otherwise
      :rtype: bool
  
      >>> secret = b'MFRGGZDFMZTWQ2LK'
      >>> token = get_totp(secret)
      >>> valid_totp(token, secret)
      True
      >>> valid_totp(token+1, secret)
      False
      >>> token = get_totp(secret, as_string=True)
      >>> valid_totp(token, secret)
      True
      >>> valid_totp(token + b'1', secret)
      False
      """
      if _is_possible_token(token, token_length=token_length):
          if clock is None:
              clock = time.time()
          for w in range(-window, window+1):
              if int(token) == get_totp(
                  secret,
                  digest_method=digest_method,
                  token_length=token_length,
                  interval_length=interval_length,
                  clock=int(clock)+(w*interval_length)
              ):
                  return True
      return False
code_tokens: def valid_totp ( token , secret , digest_method = hashlib . sha1 , token_length = 6 , interval_length = 30 , clock = None , window = 0 , ) : if _is_possible_token ( token , token_length = token_length ) : if clock is None : clock = time . time ( ) for w in range ( - window , window + 1 ) : if int ( token ) == get_totp ( secret , digest_method = digest_method , token_length = token_length , interval_length = interval_length , clock = int ( clock ) + ( w * interval_length ) ) : return True return False
short_docstring: Check if given token is valid time-based one-time password for given
  secret.
short_docstring_tokens: Check if given token is valid time - based one - time password for given secret .
comment: """Check if given token is valid time-based one-time password for given
      secret.
  
      :param token: token which is being checked
      :type token: int or str
      :param secret: secret for which the token is being checked
      :type secret: str
      :param digest_method: method of generating digest (hashlib.sha1 by default)
      :type digest_method: callable
      :param token_length: length of the token (6 by default)
      :type token_length: int
      :param interval_length: length of TOTP interval (30 seconds by default)
      :type interval_length: int
      :param clock: time in epoch seconds to generate totp for, default is now
      :type clock: int
      :param window: compensate for clock skew, number of intervals to check on
          each side of the current time. (default is 0 - only check the current
          clock time)
      :type window: int (positive)
      :return: True, if is valid token, False otherwise
      :rtype: bool
  
      >>> secret = b'MFRGGZDFMZTWQ2LK'
      >>> token = get_totp(secret)
      >>> valid_totp(token, secret)
      True
      >>> valid_totp(token+1, secret)
      False
      >>> token = get_totp(secret, as_string=True)
      >>> valid_totp(token, secret)
      True
      >>> valid_totp(token + b'1', secret)
      False
      """