otp

package
v0.3.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 9, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotSecret        error = errors.New("no secret key provided")
	ErrBadSecret        error = errors.New("bad secret key")
	ErrInvalidAlgorithm error = errors.New("invalid algorithm. Please use any one of SHA1/SHA256/SHA512")
	ErrUnableCompute    error = errors.New("unable to compute HMAC")
)

Functions

func NewTOTP

func NewTOTP(key string, opts ...TOption) *totp

Types

type OTP

type OTP interface {
	Generate() (string, error)
	URL() string
	Validate(token string) (ok bool, e error)
}

type TOption

type TOption func(*totp)

func TOTPWithAlgorithm

func TOTPWithAlgorithm(algo string) TOption

func TOTPWithDelay

func TOTPWithDelay(n int) TOption

func TOTPWithDigits

func TOTPWithDigits(n int) TOption

func TOTPWithPeriod

func TOTPWithPeriod(ts int64) TOption

func TOTPWithUinx

func TOTPWithUinx(ts int64) TOption

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL