hotp

package
v0.0.0-...-bcc872a Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2020 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrHOTPOptionIsNil = errors.New("hotp option is nil")

ErrHOTPOptionIsNil is an error when the hotp option is nil

Functions

func GeneratePasscode

func GeneratePasscode(secret string, counter uint64) (string, error)

GeneratePasscode generates a passcode with using default value of option

func GeneratePasscodeWithOption

func GeneratePasscodeWithOption(secret string, counter uint64, opt *Option) (string, error)

GeneratePasscodeWithOption generates a passcode This function can pass custom value of option When this executes, it returns a HMAC-based One Time Password See: https://tools.ietf.org/html/rfc4226#section-5.2

func Validate

func Validate(passcode string, secret string, counter uint64) (bool, error)

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

func ValidateWithOption

func ValidateWithOption(passcode string, secret string, counter uint64, opt *Option) (bool, error)

ValidateWithOption validates a HMAC-based One Time Password This function can pass custom value of option

Types

type Option

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

Option is used when operates the HMAC-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

Jump to

Keyboard shortcuts

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