def get_token(...):
...
msg = struct.pack(">Q", int(time / seconds))
r = hmac.new(secret, msg, sha1).digest()
k = r[19]
idx = k & 0x0f
h = struct.unpack(">L", r[idx:idx + 4])[0] & 0x7fffffff
return h % (10 ** digits), -(time % seconds - seconds)
I'm replacing it with pyotp to simplify things. Unfortunately, I do use that second return parameter, which is the time remaining for the code's validity. I use it to show how long the user's code is still valid for, and to decide when to generate a new one.
I understand why at() doesn't return the time remaining but having it in generate_otp() at the very least would make this functionality possible.
I have the following code in my library:
I'm replacing it with pyotp to simplify things. Unfortunately, I do use that second return parameter, which is the time remaining for the code's validity. I use it to show how long the user's code is still valid for, and to decide when to generate a new one.
I understand why at() doesn't return the time remaining but having it in generate_otp() at the very least would make this functionality possible.
Thanks!