totp

package module
v0.0.0-...-08f24c2 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2024 License: LGPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Examples

Constants

View Source
const DIGITS = 6 // %06d
View Source
const PERIOD = 30 // 30s

Variables

This section is empty.

Functions

func GenAuthRule

func GenAuthRule(label, issuer, secret, algorithm string, periodDigits ...int) string

func GenSecret

func GenSecret() (string, error)
Example
package main

import (
	"fmt"
	"log"

	"github.com/watsonserve/goutil/totp"
)

func main() {
	s, err := totp.GenSecret()
	if nil != err {
		log.Fatalln(err)
	}

	r := totp.GenAuthRule("label", "issuer", s, "SHA512")
	fmt.Println(r)
}
Output:

func GenTotp

func GenTotp(secret string, algorithm func() hash.Hash, periodDigits ...int) (string, error)
Example
package main

import (
	"crypto/sha512"
	"fmt"

	"github.com/watsonserve/goutil/totp"
)

func main() {
	fmt.Println(totp.GenTotp("EVGUUICK6MMMVPHSW4GTBBAETHDEPC5S", sha512.New))
}
Output:

Types

This section is empty.

Jump to

Keyboard shortcuts

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