otp

package module
v0.0.0-...-85adc57 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2025 License: ISC Imports: 6 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 interface {
	// Validate checks if the provided OTP code is valid.
	Validate(code string) bool

	// URI retrieves the otpauth:// URI used by authenticator apps.
	URI() string

	// QR generates a QR code as a PNG byte slice based on the otpauth URI.
	QR() ([]byte, error)
}

OTP validating codes, retrieving the setup URI, and generating QR code images for One-Time Password (OTP).

func NewGoogleOTP

func NewGoogleOTP(username, issuer string, period Period, ids ...string) (OTP, error)

NewGoogleOTP create new Google Authenticator OTP driver.

type Period

type Period uint

Period represents the time duration (in seconds) for OTP validity.

const (
	// Period30 defines a 30-second OTP validity period.
	Period30 Period = 30

	// Period60 defines a 60-second OTP validity period.
	Period60 Period = 60
)

Jump to

Keyboard shortcuts

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