# googleAuthenticator **Repository Path**: medusa/googleAuthenticator ## Basic Information - **Project Name**: googleAuthenticator - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2021-05-17 - **Last Updated**: 2021-05-17 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README #Google Authenticator Golang package This Golang package can be used to interact with the Google Authenticator mobile app for 2-factor-authentication. This package can generate secrets, generate codes and validate codes the secret. For a secret installation you have to make sure that used codes cannot be reused (replay-attack). #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)) > }