util

package
v0.0.0-...-6f04214 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2019 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OtpTypeTotp = "totp"
	OtpTypeHotp = "hotp"
)

Variables

This section is empty.

Functions

func BuildUri

func BuildUri(otpType, secret, accountName, issuerName, algorithm string, initialCount, digits, period int) string

生成OTP验证的URI(适用与TOTP和HOTP) https://github.com/google/google-authenticator/wiki/Key-Uri-Format * 参数说明:

otpType:		otp类型,必须是totp/hotp
secret:			用于生成URI的hotp/totp secret
accountName:	账号名
issuerName:		OTP发行人名称,这是OTP的组织标题
algorithm:		算法名称
initialCount:	计数器开始值,只用于hotp
digits:			OTP Code生成的长度
period:			OTP Code的过期时间(秒)

返回值:

用于OTP验证的URI

func CurrentTimestamp

func CurrentTimestamp() int

获取当前时间戳

func Itob

func Itob(integer int) []byte

整型转字节数组

func RandomSecret

func RandomSecret(length int) string

根据长度生成随机Secret

Types

This section is empty.

Jump to

Keyboard shortcuts

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