Пример #1
0
    def __call__(self, key, data_input):
        '''Compute an HOTP digest using the given key and data input and
           following the current crypto function description.

           :param key:
               a byte string containing the HMAC key

           :param data_input:
               the data input assembled as a byte-string as described by the
               OCRA specification
           :returns:
               the computed digest
           :rtype: str
        '''
        h = hmac.new(key, data_input, self.hash_algo).digest()
        if self.truncation_length:
            return hotp.dec(h, self.truncation_length)
        else:
            return str(hotp.truncated_value(h))
Пример #2
0
 def __call__(self, key, data_input):
     h = hmac.new(key, data_input, self.hash_algo).digest()
     if self.truncation_length:
         return str(hotp.truncated_value(h))[-self.truncation_length:]
     else:
         return str(hotp.truncated_value(h))