Documentation
¶
Index ¶
- type Google
- func (g *Google) GetCode(timestamp int64, secret string) (string, error)
- func (g *Google) GetQrcode(user, secret string) string
- func (g *Google) GetQrcodeURL(user, secret string) string
- func (g *Google) GetSecret() string
- func (g *Google) SetWindow(window int64)
- func (g *Google) VerifyCode(secret, code string) (bool, error)
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 (*Google) GetQrcodeURL ¶
GetQrcodeURL 获取动态码二维码图片地址,这里是第三方二维码api
Click to show internal directories.
Click to hide internal directories.