totp

totp(time-based one-time password) is an algorithm to generate otp from the unix time.

example

Uint8Array.toTOTP.js

1. generate a counter from the division of the unix time by the time step.
2. generate hmac from the decoded secret key and the counter.
3. from hmac, use the lowest 4bits as an index to get a 4bytes value.
4. from 3, delete the sign bit to get the lowest 6digits.

2-4 use the same algorithm as hotp(hmac-based one-time password).