himitsu/totp/totp.go

23 lines
349 B
Go
Raw Normal View History

2024-04-28 21:35:37 +02:00
package totp
import (
"himitsu/utils"
"strings"
"time"
totpLib "github.com/pquerna/otp/totp"
)
type TOTP struct {
Label string
Secret string
Account string
}
func GetCode(secret string) string {
code, err := totpLib.GenerateCode(strings.ToUpper(strings.ReplaceAll(secret, " ", "")), time.Now())
utils.CheckError(err)
return code
}