domain

package
v0.0.0-...-a953f5f Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Algorithm

type Algorithm int

Algorithm represents the hashing function to use in the HMAC operation needed for OTPs.

const (
	AlgorithmNull Algorithm = iota
	// AlgorithmSHA1 should be used for iOS & android with Google Authenticator.
	AlgorithmSHA1
	AlgorithmSHA256
	AlgorithmSHA512
	AlgorithmMD5
)

func (Algorithm) Hash

func (a Algorithm) Hash() hash.Hash

Hash .

type Config

type Config struct {
	// Number of seconds a TOTP hash is valid for. Defaults to 30 seconds.
	Period uint
	// Size in size of the generated Secret. Defaults to 20 bytes.
	SecretSize uint
	// Secret to store. Defaults to a randomly generated secret of SecretSize.  You should generally leave this empty.
	Secret []byte
	// Periods before or after the current time to allow.  Value of 1 allows up to Period
	// of either side of the specified time.  Defaults to 0 allowed skews.  Values greater
	// than 1 are likely sketchy.
	Skew uint
	// Digits represents the number of digits present in the user's OTP passcode. Six and Eight are the most common values.
	Digits Digits
	// Algorithm to use for HMAC. Defaults to SHA1.
	Algorithm Algorithm
}

type Digits

type Digits int

Digits represents the number of digits present in the user's OTP passcode. Six or Eight

const (
	DigitsNull  Digits = 0
	DigitsSix   Digits = 6
	DigitsEight Digits = 8
)

func (*Digits) Value

func (d *Digits) Value() int

type Hotp

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

Hotp HMAC-based One-Time Password

func (*Hotp) GenerateCode

func (h *Hotp) GenerateCode(counter uint64) (passcode string, err error)

GenerateCode uses a counter and secret value to create a passcode.

Jump to

Keyboard shortcuts

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