secretcode

package
v0.0.0-...-81dc835 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2024 License: Apache-2.0 Imports: 14 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
var LinkOTPSecretCode = LinkOTPSecretCodeType{}
View Source
var OOBOTPSecretCode = OOBOTPSecretCodeType{}
View Source
var RecoveryCode = RecoveryCodeType{}

Functions

func QRCodeImageFromURI

func QRCodeImageFromURI(uri string, width int, height int) (image.Image, error)

Types

type LinkOTPSecretCodeType

type LinkOTPSecretCodeType struct{}

func (LinkOTPSecretCodeType) CheckFormat

func (LinkOTPSecretCodeType) CheckFormat(value interface{}) error

func (LinkOTPSecretCodeType) Compare

func (LinkOTPSecretCodeType) Compare(a, b string) bool

func (LinkOTPSecretCodeType) Generate

func (LinkOTPSecretCodeType) Generate() string

func (LinkOTPSecretCodeType) GenerateDeterministic

func (LinkOTPSecretCodeType) GenerateDeterministic(data string) string

func (LinkOTPSecretCodeType) Length

func (LinkOTPSecretCodeType) Length() int

type OOBOTPSecretCodeType

type OOBOTPSecretCodeType struct{}

func (OOBOTPSecretCodeType) CheckFormat

func (OOBOTPSecretCodeType) CheckFormat(value interface{}) error

func (OOBOTPSecretCodeType) Compare

func (OOBOTPSecretCodeType) Compare(a, b string) bool

func (OOBOTPSecretCodeType) Generate

func (OOBOTPSecretCodeType) Generate() string

func (OOBOTPSecretCodeType) GenerateFixed

func (OOBOTPSecretCodeType) GenerateFixed(fixedCode string) string

func (OOBOTPSecretCodeType) Length

func (OOBOTPSecretCodeType) Length() int

type QRCodeImageOptions

type QRCodeImageOptions struct {
	Issuer      string
	AccountName string
	Width       int
	Height      int
}

type RecoveryCodeType

type RecoveryCodeType struct{}

func (RecoveryCodeType) CheckFormat

func (t RecoveryCodeType) CheckFormat(value interface{}) error

func (RecoveryCodeType) FormatForComparison

func (RecoveryCodeType) FormatForComparison(code string) (formatted string, err error)

func (RecoveryCodeType) FormatForHuman

func (RecoveryCodeType) FormatForHuman(code string) (formatted string)

func (RecoveryCodeType) Generate

func (RecoveryCodeType) Generate() string

type TOTP

type TOTP struct {
	Secret string
}

func NewTOTPFromRNG

func NewTOTPFromRNG() (*TOTP, error)

NewTOTPSecretFromRNG generates random TOTP secret encoded in Base32 without Padding.

func NewTOTPFromSecret

func NewTOTPFromSecret(secret string) (*TOTP, error)

func (*TOTP) GenerateCode

func (c *TOTP) GenerateCode(t time.Time) (string, error)

GenerateCode generates the TOTP code against the secret at the given time t.

func (*TOTP) GetURI

func (c *TOTP) GetURI(opts URIOptions) *url.URL

func (*TOTP) QRCodeImage

func (c *TOTP) QRCodeImage(opts QRCodeImageOptions) (image.Image, error)

func (*TOTP) ValidateCode

func (c *TOTP) ValidateCode(t time.Time, code string) bool

ValidateCode validates the TOTP code against the secret at the given time t.

type URIOptions

type URIOptions struct {
	Issuer      string
	AccountName string
}

Jump to

Keyboard shortcuts

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