totp

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2025 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package totp provides a time-based one-time password (TOTP) implementation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type TOTP

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

TOTP represents a Time-based One-Time Password

func New

func New(seed string, len int, interval uint64, skew uint8) *TOTP

New creates a new TOTP instance. nolint:revive // Keeping parameter name for backward compatibility

func (*TOTP) Generate

func (totp *TOTP) Generate() string

Generate generates a new TOTP.

func (*TOTP) GenerateCustom

func (totp *TOTP) GenerateCustom(t time.Time) string

GenerateCustom generates a new TOTP with a custom time.

func (*TOTP) Validate

func (totp *TOTP) Validate(otp string) bool

func (*TOTP) ValidateCustom

func (totp *TOTP) ValidateCustom(otp string, t time.Time) bool

ValidateCustom checks if the provided OTP is valid

Jump to

Keyboard shortcuts

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