otp

package module
v1.0.1-0...-812bd57 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2019 License: MIT Imports: 11 Imported by: 0

README

OTP

GoDoc Widget Build Status codecov Go Report Card

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RandomSecret

func RandomSecret(length int) string

Types

type Hasher

type Hasher struct {
	HashName string
	Digest   func() hash.Hash
}

type OTP

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

func NewOTP

func NewOTP(secret string, digits int, hasher *Hasher) *OTP

func (*OTP) GenerateOTP

func (o *OTP) GenerateOTP(input int) string

type OTPAuthOption

type OTPAuthOption struct {
	Issuer       string
	Account      string
	InitialCount int
	Period       int
	Algorithm    string
}

type OTPType

type OTPType string
const (
	OTPTypeTOTP OTPType = "totp"
	OTPTypeHOTP OTPType = "hotp"
)

func (OTPType) OTPAuthURI

func (otpType OTPType) OTPAuthURI(secret string, digits int, opt OTPAuthOption) string

type TOTP

type TOTP struct {
	*OTP
	// contains filtered or unexported fields
}

func NewDefaultTOTP

func NewDefaultTOTP(secret string) *TOTP

func NewTOTP

func NewTOTP(secret string, digits int, interval int, hasher *Hasher) *TOTP

func (*TOTP) At

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

func (*TOTP) Now

func (t *TOTP) Now() string

func (*TOTP) NowWithExpiration

func (t *TOTP) NowWithExpiration() (string, int64)

func (*TOTP) Verify

func (t *TOTP) Verify(otp string, timestamp int64) bool

Jump to

Keyboard shortcuts

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