新增修改注册流程
This commit is contained in:
@@ -2,7 +2,10 @@ package utils
|
||||
|
||||
import (
|
||||
"math/rand"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/pquerna/otp/totp"
|
||||
)
|
||||
|
||||
type RandDateParams struct {
|
||||
@@ -73,3 +76,18 @@ func RandDate(minAge, maxAge int) RandDateParams {
|
||||
Day: day,
|
||||
}
|
||||
}
|
||||
|
||||
// 获取FA2码
|
||||
func GetFA2Code(secret string) (string, error) {
|
||||
// 去除多余的字符串
|
||||
replacer := strings.NewReplacer(
|
||||
"-", "",
|
||||
" ", "",
|
||||
)
|
||||
result := replacer.Replace(secret)
|
||||
code, err := totp.GenerateCode(result, time.Now())
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return code, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user