otp

package module
v0.0.0-...-862ae98 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2023 License: MIT Imports: 9 Imported by: 0

README

go-otp

OTP - One time password - implementation based on RFC-4226 and RFC-6238 HMAC-Based One Time Password and Time-Based One time password

Documentation

Index

Constants

View Source
const (
	// 30 second interval
	DefaultInterval = 30

	OtpAuthScheme = "otpauth"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthURL

type AuthURL struct {
	Type      string
	Label     string
	Secret    string
	Issuer    string
	Algorithm string
	Counter   int
	Digits    int
	Period    int
}

func (*AuthURL) String

func (o *AuthURL) String() string

type Counter

type Counter interface {
	Count() int64
}

type HOTP

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

func (*HOTP) Counter

func (h *HOTP) Counter() Counter

func (*HOTP) GenerateCode

func (h *HOTP) GenerateCode(key string, count int64, tokenLen int) (string, error)

func (*HOTP) Hash

func (h *HOTP) Hash() crypto.Hash

func (*HOTP) VerifyCode

func (h *HOTP) VerifyCode(code, key string, skew, tokenLen int) bool

type OTP

type OTP interface {
	Counter() Counter
	Hash() crypto.Hash
	GenerateCode(key string, count int64, tokenLen int) (string, error)
	VerifyCode(code, key string, skew, tokenLen int) bool
}

func DefaultTOTP

func DefaultTOTP() OTP

func NewTOTP

func NewTOTP(hash crypto.Hash, interval, step int) OTP

type TimeCounter

type TimeCounter struct {
	Interval, Step int
}

func (*TimeCounter) Count

func (t *TimeCounter) Count() int64

Jump to

Keyboard shortcuts

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