<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def get_hotp( secret, intervals_no, as_string=False, casefold=True, digest_method=hashlib.sha1, token_length=6, ):
 """ Get HMAC-based one-time password on the basis of given secret and interval number. :param secret: the base32-encoded string acting as secret key :type secret: str or unicode :param intervals_no: interval number used for getting different tokens, it is incremented with each use :type intervals_no: int :param as_string: True if result should be padded string, False otherwise :type as_string: bool :param casefold: True (default), if should accept also lowercase alphabet :type casefold: bool :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 :return: generated HOTP token :rtype: int or str 765705 816065 True """

    if isinstance(secret, six.string_types):
        # It is unicode, convert it to bytes
        secret = secret.encode('utf-8')
    # Get rid of all the spacing:
    secret = secret.replace(b' ', b'')
    try:
        key = base64.b32decode(secret, casefold=casefold)
    except (TypeError):
        raise TypeError('Incorrect secret')
    msg = struct.pack('>Q', intervals_no)
    hmac_digest = hmac.new(key, msg, digest_method).digest()
    ob = hmac_digest[19] if six.PY3 else ord(hmac_digest[19])
    o = ob & 15
    token_base = struct.unpack('>I', hmac_digest[o:o + 4])[0] & 0x7fffffff
    token = token_base % (10 ** token_length)
    if as_string:
        # TODO: should as_string=True return unicode, not bytes?
        return six.b('{{:0{}d}}'.format(token_length).format(token))
    else:
        return token