otp

package
v0.0.0-...-642df0c Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2024 License: BSD-3-Clause Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DEBUG bool = false

	DEFAULT_LENGTH   uint8  = 256 / 8
	DEFAULT_ALGO     string = "sha384"
	DEFAULT_DIGITS   uint8  = 8
	DEFAULT_INTERVAL uint16 = 30

	URL_OTPAUTH string = "otpauth://totp/" // just for TOTP ...
)

Variables

This section is empty.

Functions

func IsSecretValid

func IsSecretValid(secret string) bool

A non-panic way of seeing weather or not a given secret is valid

func RandomSecret

func RandomSecret(length uint8) string

generate a random secret of given length (number of bytes) returns empty string if something bad happened

Types

type OTP

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

type TOTP

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

time-based OTP counters.

func NewTOTP

func NewTOTP(secret string, digits uint8, interval uint16, algo string) *TOTP

func (*TOTP) At

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

func (*TOTP) GenerateBarcodeUrl

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

func (*TOTP) Now

func (t *TOTP) Now() string

Generate the current time OTP

func (*TOTP) Verify

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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