This library implements HMAC-based One-Time Password (HOTP) and Time-based One-Time Password (TOTP) algorithms.
As this package hasn't reached v1 yet, its API shouldn't be considered stable and can change at any moment. However, it is unlikely to happen.
Using defaults :
code := otp.TOTP(secret, time.Now(), TOTPOptions{})
Using options :
code := otp.TOTP(secret, time.Now(), TOTPOptions{
HOTPOptions: HOTPOptions{
Digits: 8,
},
Period: 60,
Step: -1,
})
Default options are :
- 6 digits
- 30 seconds time period
- SHA1 hash function