# README
OTP Generator for Go
This Go package provides a simple implementation for generating One-Time Passwords (OTP) based on the HMAC-based One-Time Password Algorithm (HOTP) and Time-Based One-Time Password Algorithm (TOTP) as described in RFC 4226 and RFC 6238.
Usage
package main
import (
"crypto/sha1"
"fmt"
"time"
"github.com/GabiBizdoc/golang-playground/pgk/otp"
)
func main() {
secret := "<your base32 key"
code, _ := otp.GenerateTOTP(secret)
token := code.TakeDigitsString(6)
expireIn := time.Until(code.ExpireAt)
fmt.Println(token, expireIn)
var rawSecret []byte
bincode, _ := otp.GenerateTimeBasedOTP(sha1.New, rawSecret, 30)
token = bincode.TakeDigitsString(6)
fmt.Println(token)
}
link example otpauth://totp/application%20name?secret=123456567890&issuer=12323123123&algorithm=SHA1&digits=8&period=60
# Functions
No description provided by the author
No description provided by the author
GenerateCounterBasedOTP generates a One-Time Password (OTP) using a counter-based algorithm.
GenerateTimeBasedOTP produces a One-Time Password (OTP) code.
GenerateTOTP produces a One-Time Password (OTP) code using a base32 key.
GenerateTOTPFromBase32Key produces a One-Time Password (OTP) code using a base32 key.
No description provided by the author
No description provided by the author
# Structs
No description provided by the author
# Type aliases
No description provided by the author