totp

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2021 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrTOTPOptionIsNil = errors.New("totp option is nil")

ErrTOTPOptionIsNil is an error when the totp option is nil

Functions

func Validate

func Validate(passcode, secret string, t time.Time) (bool, error)

Validate validates a Time-based One Time Password with using default value of option

func ValidateWithOption

func ValidateWithOption(passcode, secret string, t time.Time, opt *Option) (bool, error)

ValidateWithOption validates a Time-based One Time Password This function can pass custom value of option See: https://tools.ietf.org/html/rfc6238#section-4.2

Types

type Option

type Option struct {
	// contains filtered or unexported fields
}

Option is used when operates the Time-based One Time Password

func NewOption

func NewOption() *Option

NewOption generates an option with default values

func (*Option) SetAlgorithm

func (opt *Option) SetAlgorithm(a otpauth.Algorithm) error

SetAlgorithm sets the hash algorithm

func (*Option) SetDigits

func (opt *Option) SetDigits(d otpauth.Digits) error

SetDigits sets the number of digits

func (*Option) SetPeriod

func (opt *Option) SetPeriod(period uint) error

SetPeriod sets a period that Time-based One Time Password hash is valid

func (*Option) SetSkew

func (opt *Option) SetSkew(skew uint) error

SetSkew sets a skew

Jump to

Keyboard shortcuts

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