登录相关处理
This commit is contained in:
21
utils/auth/valid_code.go
Normal file
21
utils/auth/valid_code.go
Normal file
@@ -0,0 +1,21 @@
|
||||
package auth
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"math/rand"
|
||||
)
|
||||
|
||||
func GenerateVerificationCode() string {
|
||||
var code string
|
||||
|
||||
for i := 0; i < 3; i++ {
|
||||
// 生成两个 10-99 之间的随机数
|
||||
a := rand.Intn(90-10+1) + 10
|
||||
b := rand.Intn(90-10+1) + 10
|
||||
c := rand.Intn(90-10+1) + 10
|
||||
// 将随机数拼接到验证码字符串
|
||||
code += fmt.Sprintf("%d%d%d", a, b, c)
|
||||
}
|
||||
|
||||
return code
|
||||
}
|
||||
Reference in New Issue
Block a user