auth

package module
v0.0.0-...-f21fe5c Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2021 License: MIT Imports: 8 Imported by: 0

README

googleAuth

谷歌身份验证器

usage

package main

import (
	"fmt"
)

func main() {

	auth := NewGoogleAuth()
	secret := auth.GetSecret()

	code, err := auth.GetCode(secret)
	url := auth.GetQrcodeUrl("gotest", secret)

	fmt.Println(secret, code, url, err)

	var input string

	for {
		fmt.Scanf("%s", &input)
		fmt.Println(input)

		b, err := auth.VerifyCode(secret, input)
		if err != nil || b == false{
			fmt.Println("failed")
		}else {
			fmt.Println("successful")
		}
	}

}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GoogleAuth

type GoogleAuth struct{}

func NewGoogleAuth

func NewGoogleAuth() *GoogleAuth

func (*GoogleAuth) GetCode

func (g *GoogleAuth) GetCode(secret string) (string, error)

func (*GoogleAuth) GetQrcode

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

func (*GoogleAuth) GetQrcodeUrl

func (g *GoogleAuth) GetQrcodeUrl(user, secret string) string

func (*GoogleAuth) GetSecret

func (g *GoogleAuth) GetSecret() string

func (*GoogleAuth) VerifyCode

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

Jump to

Keyboard shortcuts

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