otp

package module
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2024 License: GPL-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 GenHotp

func GenHotp(algorithm func() hash.Hash, secret string, idx int64, digits int) (string, error)

func GenSecret

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

import (
	"fmt"
	"log"

	"github.com/watsonserve/otp"
)

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

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

func GenTotp

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

import (
	"crypto/sha512"
	"fmt"

	"github.com/watsonserve/otp"
)

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

Types

This section is empty.

Jump to

Keyboard shortcuts

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