Files
lckt-server/test/rain_test.go
2025-07-20 03:07:42 +08:00

42 lines
914 B
Go

package test
import (
"fmt"
"git.echol.cn/loser/lckt/utils/sms"
"golang.org/x/crypto/bcrypt"
"math/rand"
"testing"
"time"
)
func TestRain(t *testing.T) {
rand.New(rand.NewSource(time.Now().UnixNano()))
verifyCode := fmt.Sprintf("%06v", rand.Int31n(1000000))
fmt.Println(verifyCode)
}
func TestPwd(t *testing.T) {
password, _ := bcrypt.GenerateFromPassword([]byte("loser7659"), bcrypt.DefaultCost)
fmt.Println(string(password))
err := bcrypt.CompareHashAndPassword(password, []byte("122456"))
if err != nil {
fmt.Println("密码错误")
} else {
fmt.Println("密码正确")
}
}
func TestCode(t *testing.T) {
// 测试验证码生成
rand.New(rand.NewSource(time.Now().UnixNano()))
verifyCode := fmt.Sprintf("%06v", rand.Int31n(1000000))
test := sms.SendSMSTest("17754945397", verifyCode)
if test {
fmt.Println("短信发送成功")
} else {
fmt.Println("短信发送失败")
}
}