Vestmore_GO/utils/auth/valid_code.go
2024-04-09 18:17:08 +08:00

22 lines
372 B
Go

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
}