Loading... # google令牌动态验证码 [![image](https://user-images.githubusercontent.com/80592877/178144553-04e4e294-b700-4aea-a70c-93919dea7610.png)](https://github.com/664485186/googleAuthenticator) # 谷歌Authenticator Golang包该Golang包可用于与谷歌Authenticator移动app交互,进行二次认证。 这个包可以生成秘密、生成代码和验证秘密代码 # Usage: > ``` > package main > > import ( > "flag" > "fmt" > "googleAuthenticator" > ) > > func createSecret(ga *googleAuthenticator.GAuth) string { > secret, err := ga.CreateSecret(16) > if err != nil { > return "" > } > return secret > } > > func getCode(ga *googleAuthenticator.GAuth, secret string) string { > code, err := ga.GetCode(secret) > if err != nil { > return "*" > } > return code > } > > func verifyCode(ga *googleAuthenticator.GAuth, secret, code string) bool { > // 1:30sec > ret, err := ga.VerifyCode(secret, code, 1) > if err != nil { > return false > } > return ret > } > > func main() { > flag.Parse() > secret := flag.Arg(0) > ga := googleAuthenticator.NewGAuth() > fmt.Print(getCode(ga, secret)) > } > ``` GitHub : https://github.com/21888/googleAuthenticator 最后修改:2022 年 07 月 10 日 © 允许规范转载 打赏 赞赏作者 微信 赞 4 如果觉得我的文章对你有用,请随意赞赏