Documentation
¶
Index ¶
- func Generate(opts GenerateOpts) (*otp.Key, error)
- func GenerateCode(secret string, t time.Time) (string, error)
- func GenerateCodeCustom(secret string, t time.Time, opts ValidateOpts) (passcode string, err error)
- func Validate(passcode string, secret string) bool
- func ValidateCustom(passcode string, secret string, t time.Time, opts ValidateOpts) (bool, error)
- type GenerateOpts
- type ValidateOpts
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GenerateCode ¶
GenerateCode creates a TOTP token using the current time. A shortcut for GenerateCodeCustom, GenerateCode uses a configuration that is compatible with Google-Authenticator and most clients.
func GenerateCodeCustom ¶
GenerateCodeCustom takes a timepoint and produces a passcode using a secret and the provided opts. (Under the hood, this is making an adapted call to hotp.GenerateCodeCustom)
func Validate ¶
Validate a TOTP using the current time. A shortcut for ValidateCustom, Validate uses a configuration that is compatible with Google-Authenticator and most clients.
Types ¶
type GenerateOpts ¶
type GenerateOpts struct {
// Name of the issuing Organization/Company.
Issuer string
// Name of the User's Account (eg, email address)
AccountName string
// Number of seconds a TOTP hash is valid for. Defaults to 30 seconds.
Period uint
// Size in size of the generated Secret. Defaults to 10 bytes.
SecretSize uint
// Digits to request. Defaults to 6.
Digits otp.Digits
// Algorithm to use for HMAC. Defaults to SHA1.
Algorithm otp.Algorithm
}
GenerateOpts provides options for Generate(). The default values are compatible with Google-Authenticator.
type ValidateOpts ¶
type ValidateOpts struct {
// Number of seconds a TOTP hash is valid for. Defaults to 30 seconds.
Period uint
// Periods before or after the current time to allow. Value of 1 allows up to Period
// of either side of the specified time. Defaults to 0 allowed skews. Values greater
// than 1 are likely sketchy.
Skew uint
// Digits as part of the input. Defaults to 6.
Digits otp.Digits
// Algorithm to use for HMAC. Defaults to SHA1.
Algorithm otp.Algorithm
}
ValidateOpts provides options for ValidateCustom().
Source Files
¶
- totp.go