totp

package
v0.0.0-...-ec611a4 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type OTP

type OTP struct {
	Opts
}

func NewDefaultOTP

func NewDefaultOTP(secret string) *OTP

DefaultOTP returns 6-digits HMAC-SHA-1 OTP based on given secret and counter

func NewOTP

func NewOTP(opts Opts) *OTP

NewOTP returns OTP object

func (*OTP) Generate

func (o *OTP) Generate(counter uint64) string

Generate returns otp value based on given counter

type Opts

type Opts struct {
	Digits    int
	Secret    string
	Algorithm func() hash.Hash
}

type TOTP

type TOTP struct {
	*OTP
	TimeStep int
}

func NewDefaultTOTP

func NewDefaultTOTP(secret string) *TOTP

DefaultOTP returns 6-digits HMAC-SHA-1 OTP based on given secret and counter

func NewTOTP

func NewTOTP(opts Opts, timestep int) *TOTP

NewOTP returns OTP object

func (*TOTP) At

func (t *TOTP) At(ts int64) string

func (*TOTP) Now

func (t *TOTP) Now() string

Jump to

Keyboard shortcuts

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