(self, input)
return str_code
:param input: the HMAC counter value to use as the OTP input.
            Usually either the counter, or the computed integer based on the Unix timestamp
        :type input: int
:param input: the HMAC counter value to use as the OTP input.
            Usually either the counter, or the computed integer based on the Unix timestamp
        :type input: int
: param input : the HMAC counter value to use as the OTP input . Usually either the counter or the computed integer based on the Unix timestamp : type input : int
def generate_otp(self, input):
        """
        :param input: the HMAC counter value to use as the OTP input.
            Usually either the counter, or the computed integer based on the Unix timestamp
        :type input: int
        """
        if input < 0:
            raise ValueError('input must be positive integer')
        hasher = hmac.new(self.byte_secret(), self.int_to_bytestring(input), self.digest)
        hmac_hash = bytearray(hasher.digest())
        offset = hmac_hash[-1] & 0xf
        code = ((hmac_hash[offset] & 0x7f) << 24 |
                (hmac_hash[offset + 1] & 0xff) << 16 |
                (hmac_hash[offset + 2] & 0xff) << 8 |
                (hmac_hash[offset + 3] & 0xff))
        str_code = str(code % 10 ** self.digits)
        while len(str_code) < self.digits:
            str_code = '0' + str_code

        return str_code
def generate_otp ( self , input ) : if input < 0 : raise ValueError ( 'input must be positive integer' ) hasher = hmac . new ( self . byte_secret ( ) , self . int_to_bytestring ( input ) , self . digest ) hmac_hash = bytearray ( hasher . digest ( ) ) offset = hmac_hash [ - 1 ] & 0xf code = ( ( hmac_hash [ offset ] & 0x7f ) << 24 | ( hmac_hash [ offset + 1 ] & 0xff ) << 16 | ( hmac_hash [ offset + 2 ] & 0xff ) << 8 | ( hmac_hash [ offset + 3 ] & 0xff ) ) str_code = str ( code % 10 ** self . digits ) while len ( str_code ) < self . digits : str_code = '0' + str_code return str_code