Debian Codegraph @

example/main.go

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