otp

package
v0.0.0-...-5eebb81 Latest Latest
Warning

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

Go to latest
Published: May 23, 2023 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SHA1   = HashAlgorithm("SHA1")
	SHA256 = HashAlgorithm("SHA256")
	SHA512 = HashAlgorithm("SHA512")
)

Variables

View Source
var (
	ErrInvalidLength = errors.New("invalid length")
	ErrValidation    = errors.New("otp invalid")
)

Functions

This section is empty.

Types

type Algorithm

type Algorithm interface {
	// Generate generates an otp value
	Generate(reference int64) string

	// Validate validates the given otp value for the given reference
	// opts can optionally be used to provide algorithm specific validation options
	Validate(value string, reference int64, opts ...ValidationOption) (int64, error)

	// Export exports the configuration of the algorithm
	Export(exporter Exporter)
}

type Digits

type Digits int

func (Digits) Format

func (d Digits) Format(value int32) string

func (Digits) Length

func (d Digits) Length() int

func (Digits) String

func (d Digits) String() string

type Exporter

type Exporter interface {
	SetAlgorithm(algorithm string)
	SetHashAlgorithm(algorithm HashAlgorithm)
	SetKey(key []byte)
	SetDigits(digits Digits)
	SetT0(t0 int64)
	SetPeriod(period time.Duration)
}

type HashAlgorithm

type HashAlgorithm string

func (HashAlgorithm) Hash

func (h HashAlgorithm) Hash() hash.Hash

func (HashAlgorithm) Size

func (h HashAlgorithm) Size() int

func (HashAlgorithm) String

func (h HashAlgorithm) String() string

type SkewIterator

type SkewIterator interface {
	HasNext() bool
	Value() int64
}

func NewSkewIterator

func NewSkewIterator(start, end int64) SkewIterator

type ValidationOption

type ValidationOption func(current int64) SkewIterator

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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