Versions in this module Expand all Collapse all v1 v1.6.0 Jun 4, 2026 Changes in this version + const AlgorithmCompat + const AlgorithmSecure + var ErrAlgorithmDigestInsufficient = errors.New("algorithm produces insufficient digest size for OTP generation") + var ErrColonInAccountName = errors.New("invalid colon in account name") + var ErrColonInIssuer = errors.New("invalid colon in issuer name") + var ErrDigestTooSmall = errors.New(...) + var ErrDigitsOutOfRange = errors.New(...) + var ErrGenerateMissingAccountName = errors.New("accountName must be set") + var ErrGenerateMissingIssuer = errors.New("issuer must be set") + var ErrInvalidAlgorithm = errors.New("invalid 'algorithm' parameter") + var ErrInvalidCounter = errors.New("invalid 'counter' parameter") + var ErrInvalidDigits = errors.New("invalid 'digits' parameter") + var ErrInvalidEncoder = errors.New("invalid encoder: must be EncoderDefault or EncoderSteam") + var ErrInvalidImageURL = errors.New("image URL must be a valid HTTPS URL") + var ErrInvalidPeriod = errors.New("invalid 'period' parameter") + var ErrInvalidSecretFormat = errors.New("invalid 'secret' format, must be valid Base32") + var ErrInvalidURIChars = errors.New("issuer or account name contains invalid characters (control chars)") + var ErrInvalidURIFormat = errors.New("invalid URI format") + var ErrInvalidURIScheme = errors.New("invalid URI scheme, must be otpauth://") + var ErrInvalidURIType = errors.New("invalid OTP type, must be 'hotp' or 'totp'") + var ErrMissingSecret = errors.New("missing required 'secret' parameter") + var ErrPeriodOutOfRange = errors.New("period out of range, must be between 1 and 300 seconds") + var ErrReplayAttack = errors.New("replay attack detected: time step already used") + var ErrSecretTooLong = errors.New("secret too long, must be at most 64 bytes") + var ErrSecretTooShort = errors.New("secret too short, must be at least 16 bytes") + var ErrURITooLong = errors.New("URI exceeds maximum allowed length") + var ErrValidateInputInvalidChars = errors.New("passcode contains invalid characters") + var ErrValidateInputInvalidLength = errors.New("input length unexpected") + var ErrValidateSecretInvalidBase32 = errors.New("decoding of secret as base32 failed") + var ErrWindowTooLarge = errors.New("window exceeds maximum allowed value") + type Algorithm int + const AlgorithmMD5 + const AlgorithmSHA1 + const AlgorithmSHA224 + const AlgorithmSHA256 + const AlgorithmSHA384 + const AlgorithmSHA3_224 + const AlgorithmSHA3_256 + const AlgorithmSHA3_384 + const AlgorithmSHA3_512 + const AlgorithmSHA512 + func ParseAlgorithm(name string) (Algorithm, error) + func (a Algorithm) Hash() hash.Hash + func (a Algorithm) HashChecked() (hash.Hash, error) + func (a Algorithm) IsValid() bool + func (a Algorithm) String() string + type Digits int + const DigitsEight + const DigitsSix + func (d Digits) Format(in int32) string + func (d Digits) Length() int + func (d Digits) String() string + type Encoder string + const EncoderDefault + const EncoderSteam + type Key struct + func NewKeyFromURL(orig string) (*Key, error) + func (k *Key) AccountName() string + func (k *Key) Algorithm() Algorithm + func (k *Key) Counter() uint64 + func (k *Key) Digits() Digits + func (k *Key) Encoder() Encoder + func (k *Key) GetExtraParam(key string) string + func (k *Key) Image(width int, height int) (image.Image, error) + func (k *Key) ImageURL() string + func (k *Key) Issuer() string + func (k *Key) Period() uint64 + func (k *Key) Secret() string + func (k *Key) String() string + func (k *Key) Type() string + func (k *Key) URL() string + type ValidationResult struct + Delta int + Step uint64 + Valid bool