Documentation
¶
Overview ¶
Package totp is used to generate and verify Timed One-Time Passwords.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrInvalid = errors.New("invalid")
ErrInvalid is returned when a parameter fails validation.
var ErrTokenFailed = errors.New("could not verify token")
ErrTokenFailed is returned when a TOTP fails verification.
Functions ¶
This section is empty.
Types ¶
type HashAlgorithm ¶
type HashAlgorithm int
HashAlgorithm defines which hashing algorithm to use when generating a TOTP. The default for most apps is SHA-1.
const ( SHA1 HashAlgorithm = iota SHA256 SHA512 )
Hashing algorithms. The default for most apps is SHA-1.
type Params ¶
type Params struct { Issuer string AccountName string HashAlgorithm HashAlgorithm SecretLength uint Digits uint8 Period time.Duration Lookback uint }
Params can configure optional parameters for new TOTP generation.
type TOTP ¶
type TOTP struct {
// contains filtered or unexported fields
}
TOTP is used to generate and verify Timed One Time Password tokens.
func FromString ¶
FromString loads a URI-encoded TOTP message. This should be used when loading TOTP secrets from a QR Code.
func Unmarshal ¶
Unmarshal loads a proto-encoded TOTP message. This should be used when loading TOTP secrets from storage.
func (*TOTP) Marshal ¶
Marshal serializes the TOTP object in a protobuf format. This should be used for storing a TOTP secret.
func (*TOTP) Secret ¶
Secret outputs the secret in a base32-encoded format. This is useful for copy/paste into authenticator apps when a QR code is not available. It is highly recommended to use SHA-1 with this as many apps will default to SHA-1.