Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Token ¶
type Token struct {
// contains filtered or unexported fields
}
A Token represents a virtual TOTP token that generates a Time-Based One-Time Password defined in RFC 6238.
func NewToken ¶
NewToken returns a new virtual TOTP token with parameters specified by a Key URI. The Key URI format is defined in https://github.com/google/google-authenticator/wiki/Key-Uri-Format.
Users of this library have to specify at least `secret` in query parameter as defined in the spec. Other parameters have default values like below:
- issuer = ""
- algorithm = "SHA1" (Other available options are "SHA256" and "SHA512")
- digits = 6
- period = 30
`digits` and `period` have a limited range as below:
- 6 <= digits <= 10
- 1 <= period <= 90
NewToken doesn't panic and merely returns an error should there be any violation in a Key URI passed.
func (*Token) Algorithm ¶
Algorithm returns the hash function name used to generate TOTPs. It should return "SHA1", "SHA256", or "SHA512".
func (*Token) Generate ¶
Generate returns a TOTP value calculated with the token's parameters and a specified time.