utilsMFA

package
v0.0.0-...-7ec6a99 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2023 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Table = []string{
		"A", "B", "C", "D", "E", "F", "G", "H",
		"I", "J", "K", "L", "M", "N", "O", "P",
		"Q", "R", "S", "T", "U", "V", "W", "X",
		"Y", "Z", "2", "3", "4", "5", "6", "7",
		"=",
	}

	ErrSecretLengthLss     = errors.New("secret length lss 6 error")
	ErrSecretLength        = errors.New("secret length error")
	ErrPaddingCharCount    = errors.New("padding char count error")
	ErrPaddingCharLocation = errors.New("padding char Location error")
	ErrParam               = errors.New("param error")
)

Functions

This section is empty.

Types

type GAuth

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

func NewGAuth

func NewGAuth() *GAuth

func (*GAuth) CreateSecret

func (this *GAuth) CreateSecret(lens ...int) (string, error)

CreateSecret create new secret 16 characters, randomly chosen from the allowed base32 characters.

func (*GAuth) GetCode

func (this *GAuth) GetCode(secret string, timeSlices ...int64) (string, error)

GetCode Calculate the code, with given secret and point in time

func (*GAuth) SetCodeLength

func (this *GAuth) SetCodeLength(length float64) error

SetCodeLength Set the code length, should be >=6

func (*GAuth) VerifyCode

func (this *GAuth) VerifyCode(secret, code string, discrepancy int64) (bool, error)

VerifyCode Check if the code is correct. This will accept codes starting from $discrepancy*30sec ago to $discrepancy*30sec from now

Jump to

Keyboard shortcuts

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