simple_otp

package
v0.0.0-...-184bb4f Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type TOTP

type TOTP struct {
	Secret    string   // Secret key (required)
	Digits    int      // OTP digit count (default: 6)
	Algorithm TotpAlgo // OTP Algorithm ("SHA1" or "SHA256" or "SHA512") (default: SHA1)
	Period    int64    // Period for which OTP is valid (seconds) (default: 30)
	UnixTime  int64    // (Optional) Unix Timestamp (default: Current unix timestamp)
}

Time-based One-Time Password from RFC - https://datatracker.ietf.org/doc/html/rfc6238

func (*TOTP) Generate

func (t *TOTP) Generate() (string, error)

Generate TOTP code and returns OTP as string and any error encountered.

type TotpAlgo

type TotpAlgo int
const (
	TotpNotSpecified TotpAlgo = 0
	TotpSha1         TotpAlgo = 1
	TotpSha256       TotpAlgo = 2
	TotpSha512       TotpAlgo = 3
)

Jump to

Keyboard shortcuts

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