totp

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2025 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

stolen from: https://github.com/yitsushi/totp-cli/blob/8eb8d7cac1284c57a1416996fb0b5d0c9e002923/internal/security/otp.go

Index

Constants

View Source
const (

	// DefaultLength is the default length of the generated OTP code.
	DefaultLength = 6
	// DefaultTimePeriod is the default time period for the TOTP.
	DefaultTimePeriod = 30
)

Variables

This section is empty.

Functions

func CheckTOTP

func CheckTOTP(code, secret string) error

func GenerateSecret

func GenerateSecret() (string, error)

func GenerateTOTPCode

func GenerateTOTPCode(opts GenerateOptions) (string, int64, error)

GenerateOTPCode generates an N digit TOTP from the secret Token.

func QRTOTP

func QRTOTP(secret, username string) ([]byte, error)

Types

type GenerateOptions

type GenerateOptions struct {
	When       time.Time
	Token      string
	TimePeriod int64
	Length     uint
}

GenerateOptions is the option list for the GenerateOTPCode function.

Jump to

Keyboard shortcuts

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