otp

package
v0.0.0-...-d8975ec Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OtpTypeTotp = "totp"
	OtpTypeHotp = "hotp"
)

Variables

This section is empty.

Functions

func BuildUri

func BuildUri(otpType, secret, accountName, issuerName, algorithm string, initialCount, digits, period int) string

func Itob

func Itob(integer int) []byte

func RandomSecret

func RandomSecret(length int) string

Types

type HOTP

type HOTP struct {
	OTP
}

func NewDefaultHOTP

func NewDefaultHOTP(secret string) *HOTP

func NewHOTP

func NewHOTP(secret string, digits int, hasher *Hasher) *HOTP

func (*HOTP) At

func (h *HOTP) At(count int) string

func (*HOTP) ProvisioningUri

func (h *HOTP) ProvisioningUri(accountName, issuerName string, initialCount int) string

func (*HOTP) Verify

func (h *HOTP) Verify(otp string, count int) bool

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

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, interval int, hasher *Hasher) *TOTP

func (*TOTP) At

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

func (*TOTP) Now

func (t *TOTP) Now() string

func (*TOTP) NowWithExpiration

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

func (*TOTP) ProvisioningUri

func (t *TOTP) ProvisioningUri(accountName, issuerName string) string

func (*TOTP) Verify

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

Jump to

Keyboard shortcuts

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