@staticmethod
def totp(key):

    def dec_to_bytes(n):
        if (n > 0):
            return (dec_to_bytes((n // 256)) + bytes([(n % 256)]))
        else:
            return b''

    def hex_to_dec(n):
        return int(n, base=16)

    def base32_to_bytes(n):
        missing_padding = (len(n) % 8)
        padding = ((8 - missing_padding) if (missing_padding > 0) else 0)
        padded = (n.upper() + ('=' * padding))
        return base64.b32decode(padded)
    epoch = (int(time.time()) // 30)
    hmac_res = Exchange.hmac(dec_to_bytes(epoch).rjust(8, b'\x00'), base32_to_bytes(key.replace(' ', '')), hashlib.sha1, 'hex')
    offset = (hex_to_dec(hmac_res[(- 1)]) * 2)
    otp = str((hex_to_dec(hmac_res[offset:(offset + 8)]) & 2147483647))
    return otp[(- 6):]
@staticmethod
def totp(key):

    def dec_to_bytes(n):
        if (n > 0):
            return (dec_to_bytes((n // 256)) + bytes([(n % 256)]))
        else:
            return b

    def hex_to_dec(n):
        return int(n, base=16)

    def base32_to_bytes(n):
        missing_padding = (len(n) % 8)
        padding = ((8 - missing_padding) if (missing_padding > 0) else 0)
        padded = (n.upper() + ('=' * padding))
        return base64.b32decode(padded)
    epoch = (int(time.time()) // 30)
    hmac_res = Exchange.hmac(dec_to_bytes(epoch).rjust(8, b'\x00'), base32_to_bytes(key.replace(' ', )), hashlib.sha1, 'hex')
    offset = (hex_to_dec(hmac_res[(- 1)]) * 2)
    otp = str((hex_to_dec(hmac_res[offset:(offset + 8)]) & 2147483647))
    return otp[(- 6):]