Documentation ¶
Overview ¶
Package totp implements Time-Based One Time Password(RFC 6238).
Index ¶
- type Decrypter
- type EncDecrypter
- type Encrypter
- type Key
- func (k *Key) GenerateCode() string
- func (k *Key) GenerateCodeAt(t time.Time) string
- func (k *Key) ToEncryptedString(encrypter Encrypter) (string, error)
- func (k *Key) URI(issuer, account string) string
- func (k *Key) ValidateCode(code string) bool
- func (k *Key) ValidateCodeAt(code string, t time.Time) bool
- type Option
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type EncDecrypter ¶
EncDecrypter is the interface that groups the basic Encrypt and Decrypt methods.
type Key ¶
type Key struct {
// contains filtered or unexported fields
}
Key is a configuration for Time-Based One Time Password(RFC 6238)
func FromEncryptedString ¶
FromEncryptedString decrypts and returns key
func (*Key) GenerateCode ¶
GenerateCode generates a TOTP code using the current time.
func (*Key) GenerateCodeAt ¶
GenerateCodeAt generates a TOTP code using a specified time.
func (*Key) ToEncryptedString ¶
ToEncryptedString converts key to encrypted string
func (*Key) URI ¶
URI returns the OTP URI as a string.
See https://github.com/google/google-authenticator/wiki/Key-Uri-Format
func (*Key) ValidateCode ¶
ValidateCode validates a TOTP code using the current time.
type Option ¶
Option is a functional option for Key constructor.
func Algorithm ¶
Algorithm returns a functional option for the TOTP algorithm.
Currently "sha1", "sha256" and "sha512" are supported.
The default value is "sha1".
func Digits ¶
Digits returns a functional option for the TOTP digits parameter that determines how long of a one-time passcode.
The default value is 6.