1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
|
package main
import (
"fmt"
"github.com/xlzd/gotp"
)
func main() {
fmt.Println("Random secret:", gotp.RandomSecret(16))
defaultTOTPUsage()
defaultHOTPUsage()
}
func defaultTOTPUsage() {
otp := gotp.NewDefaultTOTP("4S62BZNFXXSZLCRO")
fmt.Println("current one-time password is:", otp.Now())
fmt.Println("one-time password of timestamp 0 is:", otp.At(0))
fmt.Println(otp.ProvisioningUri("demoAccountName", "issuerName"))
fmt.Println(otp.Verify("179394", 1524485781))
}
func defaultHOTPUsage() {
otp := gotp.NewDefaultHOTP("4S62BZNFXXSZLCRO")
fmt.Println("one-time password of counter 0 is:", otp.At(0))
fmt.Println(otp.ProvisioningUri("demoAccountName", "issuerName", 1))
fmt.Println(otp.Verify("944181", 0))
}
|