Documentation
¶
Index ¶
Constants ¶
const ( // DefaultDigits is the default number of digits in a generated code DefaultDigits = 6 // Default period is the default number of seconds a code is valid DefaultPeriod = 30 // DefaultAlgorithm is the default algorithm used to generate codes DefaultAlgorithm = SHA1 )
Variables ¶
Functions ¶
This section is empty.
Types ¶
type TOTP ¶
type TOTP struct { Secret []byte ALgorithm Algorithm Digits uint Period uint HashFunc func() hash.Hash }
TOTP is a Time-based One-time Password algorithm implementation as described in RFC 6238. For creating use New(secret string, options *Options) (*TOTP, error)
func New ¶
Create a new TOTP instance secret is the shared secret used to generate codes, encoded as base32 string options is an optional struct for configuring the TOTP with the following fields: - Algorithm: The algorithm used to generate codes. Can be SHA1, SHA256 or SHA512. Default: SHA1 - Digits: The number of digits in a generated code. Must be between 1 and 10. Default: 6 - Period: The number of seconds a code is valid. Default: 30
func (*TOTP) GenerateAt ¶
Generate a TOTP code using the given time The timestamp must be a time.Time instance