def METHOD_NAME(key: bytes, counter: int, digits=6) -> int:
    """
    Implementation of the HOTP algorithm from `RFC 4226
    <http://tools.ietf.org/html/rfc4226#section-5>`_.
    :param bytes key: The shared secret. A 20-byte string is recommended.
    :param int counter: The password counter.
    :param int digits: The number of decimal digits to generate.
    :returns: The HOTP token.
    :rtype: int
    >>> key = b'12345678901234567890'
    >>> for c in range(10):
    ...     hotp(key, c)
    755224
    287082
    359152
    969429
    338314
    254676
    287922
    162583
    399871
    520489
    """
    msg = pack(b">Q", counter)
    hs = hmac.new(key, msg, sha1).digest()
    hs = list(iter(hs))
    offset = hs[19] & 0x0F
    bin_code = (
        (hs[offset] & 0x7F) << 24 | hs[offset + 1] << 16 | hs[offset + 2] << 8 | hs[offset + 3]
    )
    return bin_code % pow(10, digits)