Skip to content

jmolboy/googleauth

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 

Repository files navigation

GoogleAuth

google authenticator两步验证golang实现

添加引用

go get github.com/jmolboy/googleauth

使用

获取base32后的秘钥

 //strSize:随机的源字符串长度
 //RandType:随机源字符串类型:RandTypeAlphaNum=数字&字符 , RandTypeAlpha = 字母 , RandTypeNum=仅数字 
 secretKey := googleauth.RandSecret(16,googleauth.RandTypeAlphaNum)

秘钥生成二维码

img,_ :=googleauth.QrCode(secretKey,"jmol","jmolboy",200)
	

秘钥生成base64图片

base64Img,_ :=googleauth.QrBase64(secretKey,"jmol","jmolboy",200)
fmt.Print("base64:"+base64Img)

基于秘钥获取Code

code,_ := googleauth.GetCode(secretKey)
fmt.Println("code:",code)

About

google two step auth in golang

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages