🎨 complete SMS login function

This commit is contained in:
landaiqing
2024-08-14 00:11:32 +08:00
parent 48c5aeb0f4
commit 368adadf52
38 changed files with 687 additions and 232 deletions

View File

@@ -0,0 +1,20 @@
package utils
import (
"fmt"
"math/rand"
"strings"
"time"
)
func GenValidateCode(width int) string {
numeric := [10]byte{0, 1, 2, 3, 4, 5, 6, 7, 8, 9}
r := len(numeric)
rand.New(rand.NewSource(time.Now().UnixNano()))
var sb strings.Builder
for i := 0; i < width; i++ {
fmt.Fprintf(&sb, "%d", numeric[rand.Intn(r)])
}
return sb.String()
}