Versions in this module Expand all Collapse all v1 v1.0.0 Mar 28, 2022 Changes in this version + var ErrCounterRequired = fmt.Errorf("the counter is required for hotp") + var ErrInvalidCounter = fmt.Errorf("parse counter to uint failed") + var ErrInvalidDigits = fmt.Errorf("parse digits to int failed") + var ErrInvalidPeriod = fmt.Errorf("parse period to uint failed") + var ErrInvalidSecret = fmt.Errorf("the secret must be a base32 encoded string") + var ErrInvalidType = fmt.Errorf("valid type must be hotp or totp") + var ErrSecretRequired = fmt.Errorf("the secret is required") + type HOTP struct + Key []byte + func NewHOTP(key []byte) HOTP + func (otp HOTP) Generate(in interface{}, opts ...Option) string + func (otp HOTP) Validate(in interface{}, code string, opts ...Option) bool + type Key struct + Account string + Algorithm string + Counter uint64 + Digits int + Issuer string + Period int + Secret []byte + Typ string + func ParseFromURL(rawURL string) (*Key, error) + func (k *Key) Alg() func() hash.Hash + func (k *Key) QRImage(size int) ([]byte, error) + func (k *Key) RawURL() string + type OTP interface + Generate func(in interface{}, opts ...Option) string + Validate func(in interface{}, code string, opts ...Option) bool + type Option func(*Options) + func WithDigit(digit int) Option + func WithHashFunc(f func() hash.Hash) Option + func WithStartTime(start int64) Option + func WithTimeStep(step int) Option + type Options struct + Digit int + HashFunc func() hash.Hash + Leeway int + StartTime int64 + TimeStep int + func NewOptions() *Options + type TOTP struct + Key []byte + func NewTOTP(key []byte) *TOTP + func (otp TOTP) Generate(in interface{}, opts ...Option) string + func (otp TOTP) Validate(in interface{}, code string, opts ...Option) bool