otp

package
v0.0.0-...-9417291 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	DEFAULT_LENGTH uint8 = 256 / 8
	//	DEFAULT_ALGO string = "sha384"
	DEFAULT_ALGO     string = "sha512" // changed to SHA512 from SHA384 to support also Google Authenticator
	DEFAULT_DIGITS   uint8  = 8
	DEFAULT_INTERVAL uint16 = 30
	DEFAULT_ISSUER   string = "SmartGoTOTP2FA"

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

Variables

View Source
var (
	DEBUG bool = smart.DEBUG
)

Functions

func IsSecretValid

func IsSecretValid(secret string, desiredLength uint8) 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