Versions in this module Expand all Collapse all v1 v1.0.0 Jan 11, 2024 Changes in this version + var ErrSecretCannotBeEmpty = errors.New("secret cannot be empty") + var ErrSecretDecode = errors.New("secret base32 decode error") + var ErrURIFormat = errors.New("uri format error") + func Base32Decode(str string) ([]byte, error) + func Base32Encode(str []byte) string + func RandomSecret(length int) []byte + type Algorithms int + const AlgorithmSHA1 + const AlgorithmSHA256 + const AlgorithmSHA512 + func (h Algorithms) String() string + type Digits int + const DigitsEight + const DigitsSix + type HOTP struct + Secret string + func NewHOTP(secret string, options ...Option) *HOTP + func (h *HOTP) At(counter int64) string + func (h *HOTP) KeyURI(account, issuer string) *KeyURI + func (h *HOTP) Verify(token string, counter int64) bool + type KeyURI struct + Algorithm string + Counter int64 + Digits int + Issuer string + Label string + Period int + Secret string + Type string + func FromURI(uri string) (*KeyURI, error) + func (p KeyURI) QRCode() ([]byte, error) + func (p KeyURI) URI() *url.URL + type Option func(opt *Otp) + func WithAlgorithm(algorithm Algorithms) Option + func WithCounter(counter int64) Option + func WithDigits(digits Digits) Option + func WithPeriod(period int) Option + func WithSkew(skew int) Option + type Otp struct + Algorithm Algorithms + Counter int64 + Digits Digits + Period int + Skew int + type TOTP struct + Secret string + func NewTOTP(secret string, options ...Option) *TOTP + func (o *TOTP) At(t time.Time) string + func (o *TOTP) Expiration(t time.Time) int + func (o *TOTP) KeyURI(account, issuer string) *KeyURI + func (o *TOTP) Now() string + func (o *TOTP) Verify(token string, t time.Time) bool + func (o *TOTP) WithExpiration(t time.Time) (string, int)