3 ms·
I'd say these are the 4 most important, because they show the actual core of the algorithm; everything else is just input/output: mac = hmac.new(secret_byt
by userbinator 7y ago
I'd say these are the 4 most important, because they show the actual core of the algorithm; everything else is just input/output:
mac = hmac.new(secret_bytes, counter_bytes, digest).digest()
offset = mac[-1] & 0x0f
truncated = struct.unpack('>L', mac[offset:offset+4])[0] & 0x7fffffff
return str(truncated)[-digits:].rjust(digits, '0')
In other words, HMAC your secret key with the time and pick digits using the output of the HMAC.