auth

package
v0.0.0-...-59cc590 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2022 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Google

type Google struct {
	// contains filtered or unexported fields
}

Google 谷歌动态验证码

Example
secret := "B5T74E3MZERRJER2IWUB4Y7BU6DTYMWZ"

// secret最好持久化保存在
// 验证,动态码(从谷歌验证器获取或者freeotp获取)
code := "943928"
bool, err := New(6).VerifyCode(secret, code)
if bool {
	fmt.Println("√")
} else {
	fmt.Println("X", err)
}
Output:

X <nil>

func Default

func Default() *Google

New New

Example
// 秘钥
// secret := Default().GetSecret()
// fmt.Println("Secret:", secret)
Output:

func New

func New(window int64) *Google

New New

func (*Google) GetCode

func (g *Google) GetCode(timestamp int64, secret string) (string, error)

GetCode 获取动态码

func (*Google) GetQrcode

func (g *Google) GetQrcode(user, secret string) string

GetQrcode 获取动态码二维码内容

func (*Google) GetQrcodeURL

func (g *Google) GetQrcodeURL(user, secret string) string

GetQrcodeURL 获取动态码二维码图片地址,这里是第三方二维码api

func (*Google) GetSecret

func (g *Google) GetSecret() string

GetSecret 获取秘钥

func (*Google) SetWindow

func (g *Google) SetWindow(window int64)

SetWindow 设置时间窗

func (*Google) VerifyCode

func (g *Google) VerifyCode(secret, code string) (bool, error)

VerifyCode 验证动态码

Jump to

Keyboard shortcuts

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