hotp

package
v0.0.0-...-bf089be Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2018 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Generate

func Generate(opts GenerateOpts) (*otp.Key, error)

Generate 生产HOTP的密钥

func GenerateCode

func GenerateCode(secret string, counter uint64) (string, error)

GenerateCode 使用默认配置生成一次性密码

func GenerateCodeCustom

func GenerateCodeCustom(secret string, counter uint64, opts Options) (passcode string, err error)

GenerateCodeCustom 生成一个HOTP密码

func Validate

func Validate(passcode string, counter uint64, secret string) bool

Validate 使用默认配置验证HOTP密码

func ValidateCustom

func ValidateCustom(passcode string, counter uint64, secret string, opts Options) (bool, error)

ValidateCustom 使用自定义配置验证HOTP密码

Types

type GenerateOpts

type GenerateOpts struct {
	Issuer      string
	AccountName string
	SecretSize  uint
	Digits      otp.Digits
	Algorithm   otp.Algorithm
}

GenerateOpts 为Generate()方法提供配置

type Options

type Options struct {
	// Digits 表示最终计算结果的位数,默认是6位
	Digits otp.Digits
	// Algorithm 表示计算时使用的哈希算法,默认是SHA1
	Algorithm otp.Algorithm
}

Options 为GenerateCodeCustom函数提供了options

Jump to

Keyboard shortcuts

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